HUD Button set as child of Camera2d following parent of camera rather than camera itself

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

I might be misunderstanding how the node hierarchy works. But so far in the engine it seems that nodes generally move in relation to the parent but this seems to be an exception. I expected that setting a UI button as a child of the Camera2d would cause the button to remain in place on screen as a hud item. Despite this the button moves in relation to the camera’s parent and not the camera itself. The button seems to behave as if it was a child of the camera’s parent which in this case is the player. Could somebody help me understand why my expected behavior isn’t correct. and how I could resovle it?


:bust_in_silhouette: Reply From: Dlean Jeans

Dunno why it works like that.

But the best practice is to add your HUD controls as children of a CanvasLayer if you want them to stay put on the screen.

Ok make a canvas layer in your world, completely separate from the camera and everything else, and attach controls and other elements under it.

ryanscott | 2020-04-28 05:15