So Im making a 2d Platform game, my player is a tumbleweed which is a png image I found named (player and also tagged as player) the player has a ninja player controller, circle box collider and rigid body attached as well as the destroy script, I’m trying to get the player to be destroyed when it collides with another tumbleweed ( named ‘Tumble’ tagged as enemy) However it just pushes the tumble weed. can anyone tell me what im doing wrong? this is day 2 im a noob
Your OnCollisionEnter2D(Collision2D coll){...}
should be outside of your start function →
public class DestroyPlayer : Monobehavior
{
void Start(){}
void OnCollisionEnter2D(Collision2D coll){
if(coll.gameObject.tag == "Player") Destroy(coll.gameObject);
}
}