Composite Collider does not trigger OnCollisionEnter2D


I have an enemy game object that turns around whenever it hits a collider. The AI script worked properly when I had the original BoxCollider2D being used as my collider, however, I learned about tilemaps and switched to building my scenes with it.

However, the enemy now runs into the wall and does not turn around. I ran a Debug.Log and didn’t get any messages, so I’m not sure what the problem could be. I’m using Tilemap Collider 2D along with a static Rigidbody2D and Composite Collider 2D to make the ground one giant collider.

Does anyone know what else I could test for?

I figured out what the issue was.
If you’re building a level with the Tilemap tool (it’s great for 2D gam dev), be careful which tilemap is being used in a layer.
In my case, I had the enemy AI turn around when it hit a collider, however, if the collider you’re touching is the same as the collider as the ground, it won’t trigger.
The solution in my case was to just use a second tilemap and have it layered differently.
I hope this helps someone else!