+2 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:

> Player

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

1 Answer

+3 votes
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,768 points)
selected by

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

I registered just to tell you that you are a hero. I donĀ“t care how old this post is, I just learned something important.

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.