Saahil Kamat Saahil Kamat - 1 year ago 114
C# Question

Collision not getting detected in unity3d

I am making a 2D game. I have 2 game objects, a player, and some obstacles and I want the player object to be destroyed on collision. I have added box colliders to both the objects as well as tags but the collision is not taking place as there are no log messages in the console.

enter image description here

void OnCollisionEnter2D (Collision2D col)
Debug.Log("collision name = " +;
if (col.gameObject.tag == "cow") {

Answer Source

As we discussed in comments:

Add Rigidbody2D component to at least one of colliding objects.