Y-sorting enabled but not working

To ensure your player character appears behind objects in your y-sort layer, follow these steps:

Ensure Y-Sort is Enabled: Verify that Y-Sort is enabled on the parent node containing both the player and the objects.
Correct Node Hierarchy: Make sure the TileMap, Player, and Y-Sort layer are correctly placed under the parent node.
Y-Sort Order: Check the Y-Sort setting on the TileMap, Player, and Y-Sort layer. Ensure the player’s Y position is being updated correctly relative to other objects.
Here’s a concise example:

Main Scene Setup:

Main Scene (Node2D/YSort)
TileMap
Player
Y-Sort Layer (Objects with Y-Sort enabled)
Player Script:

Ensure the player’s script updates the Y position correctly:

func _process(delta):
$YSort.y_sort_mode = YSort.Y_SORT_MODE_POS
$YSort.sort()