Overlapping Physics Tilemap Layers

Godot Version

4.6

Question

Hi guys! I’ve been thinking about depth in my 2D game, especially with TileMapLayers and collisions, or maybe this is just collision in general. I want to have a void that could be covered up with some other collision layer during the game for the player to be able to walk over the void (for example, imagine a 3x3 grid with one tile missing, the void would be right in the center, cover it up with one more tile, boom, you can walk all over now). I could easily have a void object and have it spawn in and out when it’s covered up by another node with floor collision, but what about throughout a whole level? And what if that object doesn’t fully cover the void, but I still want to walk where it’s covered (for example, a bridge spawning in that crosses the void)? I’m struggling to think of an elegant solution and would love to hear if anyone has thoughts on this. Thanks!

I’m assuming that the player cannot walk over the void tile. You could just change the void tile to a normal floor tile when the covering is done. Now the tile is walkable.

I am myself making a 2D game using a TileMapLayers. I make most of the special locations (similar to your void) as a separate scenes that I add over the floor TileMapLayer. For example this kind of covareble void could be a void Sprite2D + Area2D + CollisionShape2D. When the covering is somehow triggered, some sprite animation would show the floor closing and finally the collision shape can be disabled and the player can walk over. The benefit is that I don’t need to make the structures follow the size of the TileMapLayer’s tile size and I can freely position the structures where I want. This also keeps the structure logic, graphics etc. quite well decoupled from the base structure, i.e. the TileMapLayers which handle the basic floors and walls.