0 votes

When having the HUD as a child of the main player, when smoothing is enabled the hud elements appear to drift around the screen.

Godot version 4.0.alpha2
in Engine by (24 points)

1 Answer

0 votes
Best answer

You might want to make your HUD a child of a CanvasLayer node so it's not affected by your camera

by (1,260 points)
selected by

I grouped my HUD elements as children of a canvas layer node, which itself is a child of my main player and it works! Cheers

Pseudo Hierarchy:

Root
⠀|
⠀|---Player
⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀|----- PlayerSprite2D
⠀⠀⠀⠀⠀|⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀|⠀⠀⠀⠀⠀|------ WeaponSprite2D
⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀|----- Camera2D
⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀|----- HUDCanvasLayer
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀|----- HealthSprite2D
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀|----- WeaponSelectionSprite2D
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀|----- InventorySprite2D

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.