0 votes

I've been pulling my hair out and searching everywhere to try to figure this out, and I just can't find what I'm looking for.

I'm finally getting the hang of control nodes in Godot, but I cannot figure out how to make them track with my moving Camera2D. I have a separate scene for my HUD, whose root node is just a simple control, and then all the HUD elements are set up inside of it. The root control is set to "Full Rect" in layout. This works out fine when I run the HUD scene by itself - it resizes perfectly with the game window.

I have a separate "game" scene, whose root is just a Node, and the hierarchy looks like this:

Node
> Player
>>Camera2D

The camera is a child of the player because I would like it to track the player's movement. I cannot for the life of me figure out where to put my HUD scene in this hierarchy so that it adjusts to the viewport that the camera displays on. No matter where I put it, it might as well just be a bunch of sprites I placed in the scene.

Godot version 3.2.1.stable
in Engine by (32 points)

1 Answer

+1 vote
Best answer

Create a CanvasLayer node as a child to your Node node and add your HUD as a child to that. The CanvasLayer node should follow the camera around on screen.

by (3,375 points)
selected by

Awesome, thank you so much. I knew I was just missing something simple.

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.