I am trying to make an enemy’s game object go flying when it collides with the player. Kinematic is disabled on both the player and the enemy object.
I have this code in the enemy’s class:
void OnCollisionEnter(Collision collision) {
if (collision.gameObject.tag == “Player”) {
Vector3 dir = collision.contacts[0].point - transform.position;
dir = -dir.normalized;
GetComponent().AddForce(dir * 100);
}
}
However, while the enemy object does detect the collision, I do not see it react with the force of the Player.
Any ideas on what could be happening?