Can I create a node that draws on top of others (2D), but inherits the position of the parent

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

I need to make a HPbar dor an NPC.
The ProgressBar is inherited from the control and therefore has no z-index.
I’ve tried putting the node in a CanvasLayer, but then it doesn’t move with the character. The question is whether it can be solved by build-in methods?
(Of course, I can give all nodes a negative z-index, but this is not good)

:bust_in_silhouette: Reply From: Gluon

I am not sure why you dont want to use the z_index? This is the built in method in godot to decide which layers to draw in which order. By ensuring you put your sprites on appropriate z_index you can decide on the draw order.

ProgressBar haven’t z-index and ignore the parent z-index

Rmn337 | 2023-01-29 03:37

Okay well I am not sure what you want here, I have progress bars in my games and it always works perfectly you just need to order them above the other sprites. You can literally just make sure the node is lower down the scene tree than the other sprite nodes to order the z_index if that is easier.

Gluon | 2023-01-29 09:58