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.

33 lines
641 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. /*
  16. ContactPoint contact = collision.contacts[0];
  17. Vector3 push = transform.position - contact.point;
  18. push.Normalize();
  19. Debug.Log("fence: " + push);
  20. rigidbody.AddForceAtPosition(push*1000, contact.point);
  21. */
  22. }
  23. }
  24. }