Godot Engine

Godot Engine

なかの31 May 2, 2024 @ 12:07pm
Making interface follow camera
This is probably a dumb question for many but... How do I make the interface follow the camera?
In my game, it literally stays at the same position it was placed on the game world, instead of following the screen.

Yes, I'm using Control objects.
Originally posted by Mike:
Look up the CanvasLayer node, basically put your UI nodes as children of a CanvasLayer and they wont be affected by the camera.
< >
Showing 1-8 of 8 comments
umop-apisdn May 2, 2024 @ 12:14pm 
It depends on how you want it to function, but an easy method might be to simply make the camera a child of the player so it follows the player around the game world instead of staying at whatever position you placed it.

Getting more advanced, you could write a script that has the camera move toward the player's position whenever some threshold is exceeded, so the player can make small movements without the camera immediately shifting position, too; be aware, though, that this promotes a different user experience that may or may not be right for your game.
なかの31 May 2, 2024 @ 12:29pm 
Yep, setting the interface elements as children worked.
It's actually quite odd that the interface is actually affected by the camera, but I guess I can survive this.

Wait... I wonder... Is it possible to set another camera to handle the interface? Like, that camera to be the interface canvas?
umop-apisdn May 2, 2024 @ 12:34pm 
Make the UI a child of the camera, so the HUD moves with it?

And yes, you can set up another viewport for other elements if you'd like to go that route, but it can get cognitively complex very quickly. In my experience, simpler is better; the less you have to hold in your mind while working on a thing, the easier it is to work on that thing.
なかの31 May 2, 2024 @ 12:44pm 
Yeah, I might have to do that.
I tried adding another camera with different layer settings for the interface, and its elements are still on the same place in the game world, so... Main camera object carrying the interface seems like the way to go.
The author of this thread has indicated that this post answers the original topic.
Mike May 2, 2024 @ 1:44pm 
Look up the CanvasLayer node, basically put your UI nodes as children of a CanvasLayer and they wont be affected by the camera.
なかの31 May 2, 2024 @ 2:17pm 
Originally posted by Mike:
Look up the CanvasLayer node, basically put your UI nodes as children of a CanvasLayer and they wont be affected by the camera.
You...
You're a MvP dude.
That's exactly what I was looking for. Thanks. :)

I was finding it weird that Godot had interfaces but had no way of making it fixed to screen, but I didn't knew about the Canvas Layer.

Again, Thanks :)
Last edited by なかの31; May 2, 2024 @ 2:17pm
umop-apisdn May 2, 2024 @ 4:00pm 
Assuming you didn't change the wording of your post, I chose to skim the forums instead of having coffee right after I woke up. For some reason, I thought you were having issues getting the camera to follow the player, not the HUD to stay on the screen.

My apologies, and thank goodness Mike can read better than I can.
なかの31 May 2, 2024 @ 4:13pm 
Heh, no problem.
< >
Showing 1-8 of 8 comments
Per page: 1530 50

Date Posted: May 2, 2024 @ 12:07pm
Posts: 8