WorldSpace Canvas not respecting parent Sorting Group

I’m working on a Top-Down 2D game, and I’m trying to get a WorldSpace-Canvas that’s a part of my “Enemy”-object to adhere to the same Sorting Order as the rest of the object.

However, the Canvas does not seem to respect the sorting order of the Sorting Group that’s a parent of the Canvas. This is causing my Canvas (a HealthBar) to be positioned behind other sprites when they are overlapping:

Is there any way to have this Canvas adhere to the same Sorting Order as the sprites for the GameObject?

Hierarchy:

Enemy (top-level GameObject)
- Graphics (Has SortingGroup-Component)
    - EnemySprite (SpriteRenderer for Enemy)
    - HealthCanvas (WorldSpace-Canvas)
       - Background (Healthbar-bg)
          - HealthValue (HealthBar-FillImage)

I have tried setting both the Position & Pivot for the Canvas to the ‘bottom’ of the Object (in the same position as the SortingGroup-Object), but this did not make any difference. It appears that the Canvas-Objects are directly using their WorldSpace-Position for their Sorting Order?

See image below: The HealthBar-Image does not get positioned in front of the ‘Player-Sprite’ until its Y-position is below it. (This is the top-most Y-position at which the HealthBar-Image gets positioned in front)

Expected/Wanted Result:
The WorldSpace-Canvas uses the same sorting order as the Sorting Group the Canvas is a child of, such that an Enemy’s HealthBar is always on the same sorting order layer as the SpriteRenderer(s) for the Enemy

Edit: Moved Hierarchy into a Code-Block so that indentation works.

Simply FYI, the UI (Canvas, RectTransform etc) are not a 2D feature but is developed by the UI team. Their forum is here: Unity Engine - Unity Discussions

Can i move this thread there? Or would I need to close this one and make a new one?

I can move your thread there, not a problem. I am assuming it’s the UI part you’re wondering about.

Moved. I left a redirect link on the 2D forum too for you,

1 Like

Anyone?
Putting a worldspace-Healthbar on a GameObject (and having it render on the same z-depth) seems like a fairly standard thing to do in 2D-games, no?

Did anyone ever get more clarity on this? Experiencing a similar issue. Is this expected behavior? Is there a workaround?

Experiencing same issue here.