0 votes

Hi I have a player sprite you can move around with a camera as a child of this sprite, so the camera moves with it. What would be the best way of fitting a GUI (labels, text boxes, etc) into this zoomed view? I don't really care about the GUI moving along with the camera as it only appears when you are stationary.

E.g. I have a colorrect node as a child of the camera which represents a text box, but I have to move it manually in the 2D space and it's not aligned perfectly. The draw screen limits of the camera isn't accurate e.g. I place the rect inside the camera "box" at the bottom in the 2D workspace but if I run the game, the rect will be more in the middle of the screen.

How do I properly do this within the camera view itself? Thanks.

in Engine by (151 points)

Try looking for containers in the Godot docs, they might be what you need.

Thanks I tried that but the containers just don't adjust properly while being a child of the camera node. If I put a camera in a container, the game just crashes.

1 Answer

+4 votes
Best answer

I would suggest not putting any UI elements as the child of the camera.
Use a canvasLayer instead and just put your UI elements in there, that's desinged for UI elements which don't move in corralation to the camera. See:

Or if you want it bound to the player Sprite, just add it there and play with it's positioning till you get it right.

by (262 points)
selected by
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.