I have tried many times to make my character y-sort but it's not working
also, I am using Godot 4.4
thank you for reading this
Make sure your scene follows this structure:
YSort
└── Character (e.g., Node2D or CharacterBody2D)
└── Sprite2D
└── CollisionShape2D
IMPORTANT: The node that moves (the character) must be a direct child of the YSort
node — not a grandchild.
Select the YSort
node.
In the Inspector, ensure the property sort_enabled
is true (enabled by default).
Godot will automatically sort all children of the YSort
node based on their Y position.
Make sure your Sprite2D
is centered inside the character node, because Y-sorting works based on the parent node’s global position, not the sprite’s offset.
Godot 4.4 still uses Z-index (under CanvasItem
), and it can override Y-sort behavior if not set correctly.
On your Sprite2D
:
Set Z-index
to 0
or leave it empty.
Uncheck Z as Relative
.
This ensures the YSort logic takes priority.
Easy — just make all of them children of the same YSort
node:
YSort
├── Player
├── Tree
├── Enemy
If you spawn characters or enemies at runtime, as long as they are children of the YSort
node, they'll be sorted properly without any extra setup.
Normally not needed with YSort
, but you can still manually change z_index
:
$Sprite2D.z_index = 1 # Force to render on top (not recommended with YSort)
If you're using TileMap nodes with tiles from a TileSet, Y-sorting is handled differently now than in Godot 3.x.
Godot 4.4 introduced:
A completely overhauled TileMap system
Scenes as tiles, layers, and custom properties
Automatic or manual Y-sort behavior
Use a TileMap node (not GridMap).
Assign a TileSet with tiles that have textures or scene references.
In the TileMap properties:
✅ Enable Y-Sort under TileMap > Y-Sort
.
This tells Godot to draw tiles based on their Y coordinate on screen (lower Y behind, higher Y in front).
Make sure your tiles in the TileSet editor have correct offsets:
If a tree is taller than 1 tile, offset the texture so its base aligns with the tile origin.
The tile origin is the point Godot uses for sorting.
Godot sorts by the tile's visual bottom (the Y offset). If you don’t set that correctly, sorting looks broken.
Tip: For tall sprites like trees or houses, shift the texture up in the tile editor so the base of the object touches the tile origin.
If you're using scenes (prefabs) as tiles:
Your scene root should have a YSort node.
The TileMap will instantiate these scenes and Y-sorting will follow that node's position.
If you're using TileMap layers (e.g., ground, objects, roofs):
You can have multiple TileMap nodes (one per layer), each with Y-sorting enabled.
Godot does not automatically sort between layers — you must manage layer Z-indices or draw order manually.
Your player sprite (or enemy, NPC) should be:
In a YSort
node
Positioned in the same Y axis space as your TileMap
Then Godot will sort the player in relation to tiles (if all YSort nodes are siblings or in same parent YSort).
TileMap node has Y-Sort: ON
Your tiles in the TileSet have proper offsets and alignment
Your visual layers (ground, objects) have proper Z-index if layered separately
If using scenes as tiles, their root nodes have YSort
Characters exist inside YSort containers and are placed at the same coordinate space as the tilemap
Here’s how to test Y-sorting quickly:
Make two tiles: a grass tile and a tree tile (with transparent top).
In your TileSet, shift the tree tile up by 32px (so the base is centered).
Place the grass and tree tiles on a TileMap with Y-sorting ON.
Move your character (in a YSort) behind and in front of the tree.
Boom — you’ll see it visually sort properly based on Y.