Unity 2D object collision not registering.

I have the code

 void OnCollisionEnter2D(Collision col)

        Debug.Log("bullet hit somehting"); ...

My problem is it never logs although the bullet does stop at the wall. I have both the bullet and the wall set at a z of 10 although I pause after shooting and the wall and bullet are not lined up and still say the position of their z is 10. If more information is need please ask. Thanks for the help.

  • In 2D the z-axis is not considered so even if you place your all gameObjects at same z axis or different they will work together as if they are one same plane

2D Physics Engine and 3D Physics Engine of unity are completely different.Since you are doing that in 2D you should use Collision2D instead of Collision

void OnCollisionEnter2D(Collision2D col)
       //Make sure you got rigidbody2D component attached to your bullet

2D script methods require 2D variable types as well.

Switch from “Collision” to “Collision2D”