How to build a 2D HUD in Godot 3?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bastilo


right now I’m porting my game from Godot 2 to Godot 3. It’s a 2D game with a HUD on the right side of the screen. In Godot 2 I used the following structure:

→ Game (Root node)
→ MainGameArea (Control)
—> Viewport
----> MainGame (Instance to the Main Game (without the HUD))
– > HUD (Instance to the HUD which is a CanvasLayer)

That worked pretty fine in Godot 3 but not in Godot 2. I tried to change the MainGameArea to a ViewportContainer but I still can’t see the MainGame scene. I only see the HUD and hear the music of the MainGame scene playing, so the scene is loaded but not visible.

How can I solve this problem or is there a better way to do this?

Why do you need a Viewport? The root of the scene tree already is one.

Also it looks like your HUD should work, so if your problem is that you can’t see your game viewport, you should change your topic title.

Zylann | 2018-02-13 14:04

I want to use a Viewport so the main character (with the camera attached) in always in the center of that area and not in the center of the window. It should be in the center of the window minus the space for the HUD on the side.

bastilo | 2018-02-13 16:05