Quick answer: Since Godot 4.3 each layer is its own TileMapLayer node, sorted like any other 2D node: by z_index, then scene tree order. For walls the player can walk in front of and behind, put the layers and the player under one parent with Y Sort Enabled, turn on y-sort on the wall layer, and tune each tile's Y Sort Origin.

Ground, decoration, walls and characters all have to agree on who is drawn on top. Godot gives you three tools for it — z_index, tree order and y-sorting — and the problems come from mixing them without a plan.

TileMap vs TileMapLayer

Godot 4.3 deprecated the multi-layer TileMap node in favour of one TileMapLayer node per layer. In older projects, layers are configured in the TileMap's Layers list, each with its own Z Index and Y Sort settings. The rules below apply to both; with TileMapLayer you just set them on each node.

Rule 1: z_index first, then tree order

Layers with a higher z_index draw on top. With equal z_index, the node lower in the scene tree draws on top. A simple top-down setup:

Level (Node2D)
├── Ground (TileMapLayer, z_index 0)
├── Decor (TileMapLayer, z_index 0)
└── Player (CharacterBody2D, z_index 0)

If the player is drawn under the decor, it is either above it in the tree or has a lower z_index.

Rule 2: per-tile z_index

Individual tiles can set their own Z Index in the TileSet editor (tile Rendering properties). A single tree trunk tile with z_index 1 will draw over the player even though its layer is below. Check this first when only certain tiles misbehave.

Rule 3: y-sort for things you walk behind

For walls, trees and furniture that the player should pass both in front of and behind:

  1. Enable Y Sort Enabled on the common parent (the Level node).
  2. Put the wall TileMapLayer and the player as children of that parent, with the same z_index.
  3. Enable Y Sort Enabled on the wall TileMapLayer itself so its tiles sort individually.
  4. In the TileSet, set each tall tile's Y Sort Origin to where its base touches the ground.

Keep the ground layer at a lower z_index (for example -1) so it never sorts above characters.

Common mistakes

Related fixes