Reputation: 15
I need the bounce of an object when it collides with the player depending on the direction of the player.
Upvotes: 0
Views: 59
Reputation: 1550
Adding a force to the tree in the direction from the player to the tree should do it.
Vector3 dir = treeTransform.position - playerTransform.position;
treeRb.AddForce(dir*force, ForceMode.Impulse);
If the origin of the tree is off center or the tree doesn't tilt enough you can also use AddForceAtPosition
Upvotes: 1