This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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 (25 points)

1 Answer

+1 vote
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,346 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 Frequently asked questions and 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 [email protected] with your username.