Quick answer: Use separate TileMapLayer nodes per concern. Floor (no Y-sort, no collision). Walls (no Y-sort, collision). Foreground (Y-sorted with player, no collision). Set y_sort_origin on tall tiles to match visual base.

Single TileMapLayer holds everything. Y-sort makes player walk behind walls but collision shape positions look off because they’re bound to visual sort order.

The Symptom

Y-sorted tiles look right but player collides with invisible walls or passes through visible ones. Mixing visual sort with collision coupling produces the bug.

The Fix

Level scene:
  TileMapLayerFloor    (y_sort_enabled = false, no physics)
  TileMapLayerWalls    (y_sort_enabled = false, physics layer 1)
  Player               (y_sort_enabled in parent Node2D)
  TileMapLayerProps    (y_sort_enabled = true, no physics)

Each layer has one role. Y-sort applies only to the foreground props that need to layer with the player.

y_sort_origin

For tall tiles (a tree where collision is at base but visual is up the trunk), edit the TileSet, set Y Sort Origin per tile to the base offset. Y-sort then sorts by base, not by tile origin.

Verifying

Player walks behind tall props correctly. Walls collide where the visual edge is. Floor tiles never block. No mismatch.

“Layer per role. Y-sort and collision separate concerns.”

Related Issues

For TileMapLayer physics update, see physics update. For CanvasLayer z order, see z order.

Layer per role. Sort and collide cleanly.