PathFollow2D - Y-sort issue

Godot Version

4.6

Question

In my TowerDefense game I got to the part that I need to solve the Y-Sort of all of my objects in my levels. For starters I have a Root node called LevelRoot where all of the gameplay will be happening. When You choose a level then that level is loaded through code and inside the level my tree is like follows:

LevelRoot

  • Stage01
    • GroundTileMap
    • PathTileMap
    • Y-SORT - Node2D
      • WorldObjectTileMap
      • TowerContainer
      • EnemyContainer - This is what I added still not implemented
    • Path2D

So the Wavespawner creates and Enemy and a PathFollow2D and adds it to the Path2D and they move along the path. I tried putting the Path2D under the Y-sort Node but after searching online I learned that due to the enemies are far under the Path2D tree they won’t Y-sort correctly.

One way that I saw online that was used as a solution was through a RemoteTransform2D but all of the videos and posts that I found were from a couple of years back and I wanted to ask if there was another solution to this now.
I am asking to learn more before I start implementing all of these changes.

Thank You for your time.

You need to enable CanvasItem.y_sort_enabled in any node you want its children to be y-sorted.

With Y-sorting enabled on a parent node (‘A’) but disabled on a child node (‘B’), the child node (‘B’) is sorted but its children (‘C1’, ‘C2’, etc.) render together on the same Y position as the child node (‘B’). This allows you to organize the render order of a scene without changing the scene tree.

Enable it in the parents of the nodes you want to y-sort

Yeah I had those active for every concerned element but after checking I found the issue which was my tower’s Z was set to 1 while the others were at 0 so by setting them all to 1 with active Y-sort the path follow 2D worked like a charm and I didn’t even need to move it I just had my path2d under the Y-sort.