How to make UI elements that don't move when the camera2D moves.

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

So I want to add a settings icon like you see here at the top right corner. And I don’t want camera movement to impact it. It needs to always be at that spot.

:bust_in_silhouette: Reply From: Maskass

i think you can try code a movement for the icon so it always moves the opposite of the camera movement
or a function which sends idefinetly the icon to his x,y coordinates

This is a poor way to resolve the issue. You should use a CanvasLayer node and put your HUD nodes as a child of the CanvasLayer node instead.

Calinou | 2022-07-13 00:29

Hi I am OP. I tried this solution(Canvas Layer) but it’s not really working. I have just moved my project to viewport because I was also doing split screen. And this way even when player moves the viewport stays in the same place so my UI also stays in the same place.

But the canvas layer I wanted to try out. But it’s not working. Do I need to enable something? I’ll keep trying.

Skydome | 2022-07-13 22:34

:bust_in_silhouette: Reply From: the_maven

Godot Docs:
» Your first 2D game » Heads up display:
Heads up display — Godot Engine (stable) documentation in English;

» User Interface (UI):
User interface (UI) — Godot Engine (stable) documentation in English.

Thank you. I actually had figured this out and hid the question but your answer came before I could hide. BTW the links you posted are broken.

Skydome | 2022-07-12 13:09