+1 vote

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?


in Engine by (15 points)

1 Answer

+2 votes

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.

by (4,081 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.