Unity 2D layer collision not working

I have two objects:
“Player” is an object that has a box collider 2d and a rigidbody2d, and is set on the “player” layer.
“Enemy” is an object that only has a box collider 2d, and is set on the “enemy” layer.

When the player moves, I want it to get stuck on the enemy if they touch, but the collision doesn’t work, and they go through each other.
I tried using this: Unity - Manual: Layer-based collision detection
but it still isn’t working.
The layer collision matrix looks like this:
alt text

Is there anything I’m missing?
Any help would be appreciated ^^

Note:player and enemy objects details are in comments

In my case, I mistakenly edited the Physics collision matrix instead of the Physics2D collision matrix!

@Lineweaver
You have “Is Trigger” checked on your enemy object collider. That means the objects won’t collide with the rigidbody and will only trigger the OnTriggerEnter method.

If that wasn’t your intention, try unchecking that box and see what happens

I figured it out!
Turns out that the problem was the “kinametic” body type of the rigidbody of the player object.
I changed it to “Dynamic” and set the gravity scale to zero. That way, the player collides with the enemy and still works as intended (moving around and dealing damage).

I had the same issue and was stupid enough to mistake object tag for object layer. Once I set the layer on the object right now it works

Ensure the following things are considered in your code,

  1. All gameobject should contain collider attached and the player gameobject should contain the rigidbody component in it.
  2. The collider size should change to the width and height of the component instead of default (1,1) values.
  3. Uncheck isKinematic option in Rigidbody component if it’s selected.