|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Solid_Turner |
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.
|
|
|
|
Reply From: |
timothybrentwood |
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.
Awesome, thank you so much. I knew I was just missing something simple.
Solid_Turner | 2021-05-05 13:34
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.
TrueChampignon | 2022-04-20 18:15
2 Likes
I also registered just to tell you that you are still a hero.
2 Likes
I did this and it follows my camera properly but my HUD sprites have been shrunken and transformed over 1000 pixels left and 700 pixels up. I wanted a healthbar in the lower right hand corner and in the editor thats exactly what I see. Then I hit run a suddenly my healthbar is tiny and off in the middle of my screen on the left side. I’ve been stuck on this for a week straight. I’m on gadot 4.3 btw.
Editor:
Debug:
Try setting display/window/stretch/mode
to canvas_items
in the project settings
1 Like
Good idea but that’s what I already had it set as, I also just tried all the other modes to no avail.
1 Like