Display object (sprite, GUI, box) over a camera2D

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

I have a camera2d that is zoomed in and is a a child node of my player sprite, so it follows the sprite as you walk around a large map/viewport. How would I display a GUI eg health bar over the camera view and be accurate no matter the zoom, margins, etc that I use? Like if you were replicating a 2D Zelda game with hearts on the screen, etc. Thanks.

Put them under a canvaslayer node

wombatTurkey | 2018-03-23 08:24

:bust_in_silhouette: Reply From: coffeeDragon

Put a CanvasLayer as your first node in the scene tree and add all UI elements to it.

see: Canvas layers — Godot Engine (3.0) documentation in English
CanvasLayer — Godot Engine (3.0) documentation in English

Thanks, that was surprisingly simple.

jobax | 2018-03-24 21:44