+12 votes

I have a basic scene setup that looks like this:

Scene

I have recently added the camera and figured out how to use it. The problem is that I expected the GUI (GenerateDialog) to move with the camera, but it stays in place. It is set to be in the center of the screen, which works without the camera.

Is this intended behavior? If so, how can I easily make the GUI follow the camera? How do you do this?

in Engine by (86 points)

2 Answers

+26 votes
Best answer

Add all GUI elements that need to follow the camera as a child of CanvasLayer.

by (12,889 points)
selected by

Note: Not CanvasItem.

Thank you for this info :)

Argh. I spend an hour twiddling with viewports to no avail instead. Luckily I googled in time for this answer :)

+8 votes

That's because you're not looking at Camera in the right way. This would be a better setup:

Scene

>Scenery, background tiles etc.

>Something that moves (player?)

>>Camera (so the camera will move with the player)

now you have two choices, you could make the gui a child of the camera so it moves with the camera, or...

>CanvasLayer (puts things at the very top layer even above the camera view)

>>gui stuff

by (225 points)
Thanks. In my case, the player can move the camera directly. I was just missing the canvas layer.
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 Frequently asked questions and 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 [email protected] with your username.