I followed a snake game tutorial and am trying to make it die if touches itself. For that I made a Tag for the new parts of the snake body as “Body” and wrote:
void OnCollisionEnter(Collider2D coll)
{
if (coll.gameObject.tag == "Body")
{
Debug.Log("fj");
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
For some reason this does not work, however if I set the collider2d as Trigger and add it to my OnTriggerEnter function, it works like a charm.
Are there any rules for OnCollisionEnter that I am not doing right?