[Solved] TilemapCollider2D Not Stopping GameObject

I have a tilemap with a TilemapCollider2D, CompositeCollider2D, and static Rigidbody2D. I have a GameObject with a SpriteRenderer, CapsuleCollider2D, and dynamic Rigidbody2D. My neophyte understanding of Unity indicates that this is all that should be necessary for the GameObject to fall and land on the tilemap collider. It is falling through the collider. There are NO scripts involved. I’m just trying to create one gameobject and have it fall and land on my tilemap instead of through it. I’ve tried changing collsion detection to Continuous, making sure that the collision matrix has all layers colliding (i.e. default). I’m not sure what else to check. I also have a player object that uses raycasting and it’s working fine. If I add a script to the aformentioned GameObject that isn’t being stopped with an OnTriggerEnter2D(print(“I’ve hit something”)); it works and shows that the collider is detecting the collider but I can’t figure out why the rigidbody isn’t being stopped. What am I doing wrong here?

I was going to say check that the tiles do have a collider type set a and to ensure there are collision shapes on the CompositeCollider2D (that come from the TilemapCollider2D) but going into the inspector and opening the “Info” roll-out that shows shape-count. Alternately just look at the collider gizmo which draws the shapes.

If it works as trigger then it should work otherwise and shows you have shapes so why the capsule would not contact it is very odd. You can also see contact information in the same inspector “Info > Contacts” if you pause it. You can also draw these with the gizmo setting the 2D physics project settings.

If you have a small project and could upload it then I’d be happy to take a look for you.

1 Like

I figured it out. I had added a collider to my background for the Cinemachine confiner and didn’t adjust my collision matrix.