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.
- Root (Node)
- GameWorld (Node)
- Avatar (KinematicBody2D)
- Camera (Camera2D)
- Map (Tilemap)
- ...
- Interface (CanvasLayer)
- Pause (Button)
- Health (Label)
- ...