Tiles get y-sorted based on the position of the tilemap layer

Godot Version

4.4

Question

I’ve got this very simple scene: two characters, three walls (which are made out of tiles). Everything has z-ordering set to 0.

Y-sorting works just fine between the two characters.


However, if I move a character against the north wall, it gets rendered BELOW it.

Conversely, if I move a character against the south wall, it gets rendered ABOVE it.

Meanwhile, the east wall is working exactly as it is supposed to.

What I believe is happening is that the Y-sorting mechanism is referring to the position of the tilemap layer object (look at the red line which neatly splits the east wall in an upper and a bottom part), instead on that of the individual tiles.
I could not find any past reference to this kind of behavior. I honestly thought that the position of the tilemap object was kind of irrelevant. Am I misunderstanding how tiles are y-sorted? Honestly, I completely ran out of ideas, I’ll appreciate any kind of help :folded_hands:

Your characters y-sort is not correctly setup. Here’s a small tutorial on how to correctly setup the y-sort Using Y-Sort :: Godot 4 Recipes

So, I should have used the TileMapLayer as the y-sorted parent of all other objects that are to be y-sorted relative to it? Is that how I’m supposed to manage my scenes? I removed the y-sorted Node2D and made a new parent node out of the the TileMapLayer and now it just works.

image