TilemapCollider2D is not working.

I have a player object which has a boxcollider2d and a rigidbody2D and a tilemap with a tilemapcollider2d set to trigger. The issue is that the player object passes straight through the tilemap objects without firing the ontriggerenter2d event.

If I replace the tilemap with traditional objects with boxcollider2D set to trigger then it all works fine…

What could be going wrong?

Edit---------------

Interestingly the tilemap images do not disappear if I untick the tilemap renderer (which I would expect) but do vanish if I untick the grid. Plus there are no green borders around the tiles which I would expect if they had a collider…

I think maybe you had the same misunderstanding of what TileMap does as I did. TileMapCollider creates one collider for the entire TileMap, not individual colliders for each tile. It will generate a collider with geometry merging all the tiles in the tilemap. So I’m assuming your player collider is already inside the TileMap collider and therefore not triggering.

Yes I did sort of expect to see a collider per tile. However this was not the issue. Basically there seemed to be some corruption with the scene so the tile map collisions did not work at all. I deleted the scene, created a new one and the tilemap now works as expected.

Check my answer here, maybe it would help