Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnTriggerEnter2D(Collider2D other) {
- if (other.gameObject.tag == "Player") {
- Vector2 v = other.gameObject.transform.position - this.transform.position;
- //add this line:
- Debug.Log("v: " + v);
- //Grab our collided with objects rigibody
- Rigidbody2D rigidForForce = other.gameObject.GetComponent<Rigidbody2D>();
- rigidForForce.velocity = v.normalized;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement