Topic was automatically imported from the old Question2Answer platform.
Asked By
Serenade
Old Version
Published before Godot 3 was released.
Hey!
I cant manage to pin Label text and progress bar to camera…
I have smoothing enabled and label is in Camera2D node as a child.
When player runs, camera slowly catches player up, but text is glued to the player, not the camera screen
How can i pin them to what the following camera goes?
A Camera2D is not a screen, it’s just a node telling its parent Viewport where to look at when drawing nodes (if none it will default to the main viewport).
In 2D, if you want your interface to stay at the same position on screen regardless of the camera’s position, a better idea is to put it under a CanvasLayer node.
This way, it will be drawn separately and stay pinned to where you want it to be.
Also the CanvasLayer node doesn’t have to be under the camera either, it can be under the root of your scene, as long as your “game camera” is not child of it.
Nice explanation! I’d also add you can achieve this with a CanvasLayer instead of a Viewport (not sure of any advantage to using one or the other, but it’s what I’ve used in the past).
jackmakesthings | 2017-04-01 21:41
Ah yeah, CanvasLayer would be more appropriate indeed, because it’s in 2D
Edited the answer.