Isometric Demo - How to display sprite on top of one side of the wall but not the other?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By indigo

I’m currently playing around with the isometric tilemap in Godot.

I can define a tile easily and everything looks right, but when my character moves towards a wall “above” them, they display beneath it:

I could fix this by changing the order of the scene tree, but then the sprite would display above the walls “below” them, instead of acting properly as they do ATM.

I know it’s possible to have the sprite display “on top” of the walls above and “beneath” the walls below, as that’s what is seen in the demo, but I’m not sure how to do that. Any help?

EDIT: OK, I’ve realized that if I put my character node as a child of the “Walls” node, it works, but I have no idea why. An explanation would be greatly appreciated

:bust_in_silhouette: Reply From: AlexTheRegent

Tilemap in demo uses YSort (Cell/YSort is enabled). YSort is sorting by y-position of nodes. Nodes with higher Y values are drawn last, so it looks like they are upfront. Putting your hero inside Walls node forces him to be Y-sorted too. Note that it only works for direct ascendants of YSort values (if you need to save y-sort for descendant of added nodes you need to make their parent YSort node to save sorting order).

Here’s one of the tutorials explaining how to do YSort and how it works Or you can watch any YSort tutorials to understand how it works.