Tilemap obscures objects behind it even when tiles aren't populated

Godot Version

v4.2.1.stable.official [b09f793f5]


I am making a grid-based board game and using 2 tilemaps: 1 for the board itself and a selector tilemap with a translucent rectangle that acts as a highlight for the space the mouse is over. I have pieces that are control nodes with sprites that become reparented to a canvaslayer under the board. I want the highlight to display over pieces on the board, but when I order the files as such:

BoardUI (control)
-----BoardTileMap (TileMap)
-----Pieces (CanvasLayer)
-----SelectorTileMap (TileMap)

The pieces become invisible when placed on the board, even if they are behind a space on the selector tile map that is not populated with a tile. I have the selector above the pieces for now, but that does not look right since the highlight appears behind a piece on the board.

Things I’ve tried:

  • using 2 layers on the same tilemap to be selector and board, and changing the Z-indices
  • using 2 separate tilemaps with different z indices, with pieces behind the selector but in front of the board

Things I might do instead if there is no solution with tilemaps:

  • make the selector a colorect that snaps to the tilemap and displays over each tile the mouse is over, and make this at the top z index

I found that if I make the pieces node a container instead of a CanvasLayer that i get the effect I want. Still curious if there is another way to solve this, though, or why it didn’t work before

CanvasLayers draw either above or below the entire 2D scene, depending on their layer property. That’s literally what they’re for.