Godot Version
v4.2.1
Question
I am trying to create a display that will show my game world and zoom in or out as needed. I also want to have a HUD that will display over the game world and not interact with anything and not be affected by zoom.
I thought that the best way to do this would be to make a Camera2D to display my game world and CanvasLayer nodes to separately display my Camera2D and the HUD over it. I structured my scene according to the Canvas layers tutorial. Canvas layers — Godot Engine (stable) documentation in English
So, my scene in the Godot editor looks like this:
FullScene (Type: Node2D)
CanvasLayer (Type: CanvasLayer)
Camera2D (Type: Camera2D)
Main (Type: Node)
Player (Type: Player (Custom scene that inherits from Area2D))
MobPath (Type: Path2D)
MobSpawnLocation (Type: PathFollow2D)
MobTimer (Type: Timer)
PlayerDamagedTimer (Type: Timer)
HUD (Type: CanvasLayer)
RichTextLabel (Type: RichTextLabel)
However, the Camera2D node doesn’t do anything. When I change the position or the scale, I still just see the default view starting at the origin. The documentation for Camera2D says “Cameras register themselves in the nearest Viewport node (when ascending the tree)… If no viewport is available ascending the tree, the camera will register in the global viewport.” I don’t see any classes in the tree that inherit from Viewport, so my camera should be displaying in the global viewport, meaning the window that displays when my game starts, right? Could someone please tell me why the Camera2D node isn’t doing anything?