Saahil Kamat Saahil Kamat - 1 month ago 6x
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") {


As we discussed in comments:

Add Rigidbody2D component to at least one of colliding objects.