From the docs, about Y-sort:
Nodes type relative to one another provided that they’re on the identical
z_index
.
So, you will need to set the identical Z-index for siblings Nodes you need to Y-sort as effectively.
Each Z-index and Y-sort are used to override Tree order for rendering functions, however they work considerably in a different way.
-
Z-index assigns an arbitrary “rendering precedence” to Nodes, drawing higher-index Nodes in entrance, and falls again to Tree order when drawing same-index Nodes (except Y-sort is enabled). Pattern use case: you may force-draw particles in entrance of all the pieces else presently seen, or draw a sword behind a personality regardless of the previous being a Third-level little one Node of the latter.
-
Y-sort assigns a dynamic “rendering precedence” based mostly on the vertical place of a Node’s youngsters (for siblings you may want a standard ancestor), and is affected by Z-index sorting. Pattern use case: you may accurately Y-sort floating, grounded, and underwater objects sharing the identical direct guardian as an alternative of managing three completely different Nodes for that, by merely utilizing completely different Z-indices.
Please notice that utilizing Z-index extensively could influence your sport’s efficiency, because it requires reordering draw calls earlier than sending them to the GPU.