Advertisement
Draco18s

Colliding

Dec 20th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. void OnTriggerEnter2D(Collider2D other)  {
  2.     if (other.gameObject.tag == "Player") {
  3.         Vector2 v = other.gameObject.transform.position - this.transform.position;
  4.         //add this line:
  5.         Debug.Log("v: " + v);
  6.         //Grab our collided with objects rigibody
  7.         Rigidbody2D rigidForForce = other.gameObject.GetComponent<Rigidbody2D>();
  8.         rigidForForce.velocity = v.normalized;
  9.     }
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement