How to use Viewports to make HUD?

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

I saw it in a project. It had a Camera2D and a Viewport with the HUD (and it didn’t affected by the Camera)

:bust_in_silhouette: Reply From: fpicoral

Create your hud as a scene and instantiate it on your player scene

I think it’d work. But if I have a Camera with some smoothing?

JulioYagami | 2019-02-14 01:46

Note that I have the game (that have a Camera with zoom properties and movement) and I want to add a HUD (that would be as child of the Camera). But it never works. I tried to add a viewport but it doesn’t worked, when the HUD appears the game doesn’t appears and vice versa.

JulioYagami | 2019-02-14 02:13

Some screenshots

JulioYagami | 2019-02-14 02:20

Your screenshots are not showing. Can you share the project?

fpicoral | 2019-02-14 04:26

Here is the repository:

JulioYagami | 2019-02-14 11:33

I found a solution just adding a CanvasLayer as parent of the HUD and positioning it correctly. It worked as well.

JulioYagami | 2019-02-14 11:58