I have a game object named Player which has a box collider and a rigidbody2D without kinematic.
I also have a game object named Enemy, which has a circle collider with “is trigger on” and an animation applied to it. I want to know the code to make my player die when it collides with the enemy. It is a 2d game. I am trying to make a game similar to the “Worlds Hardest Game”
This is the code im using
function OnCollisionEnter(myCol: Collision){
if(myCol.gameObject.name == "Enemy"){
Destroy(myCol.gameObject);
}
}