You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
693 B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class fence : MonoBehaviour {
  4. private Rigidbody rigidbody;
  5. // Use this for initialization
  6. void Start () {
  7. rigidbody = GetComponent<Rigidbody> ();
  8. }
  9. // Update is called once per frame
  10. void Update () {
  11. }
  12. void OnCollisionEnter(Collision collision) {
  13. if (collision.transform.tag == "moveable") {
  14. rigidbody.isKinematic = false;
  15. rigidbody.velocity = collision.relativeVelocity;
  16. /*
  17. ContactPoint contact = collision.contacts[0];
  18. Vector3 push = transform.position - contact.point;
  19. push.Normalize();
  20. Debug.Log("fence: " + push);
  21. rigidbody.AddForceAtPosition(push*1000, contact.point);
  22. */
  23. }
  24. }
  25. }