UI that should be independant of the camera

Godot Version

4.2.2 stable

Question

I created a platform game by following Brackeys’ complete tutorial. It is exceptionally well done, and my son and I managed to follow it all the way through. Now I just want to add the capability for the game to run properly on mobile phones.

To do this, I want to add a scene where I drew a joystick following this video.

The only problem is that I want the joystick to stay at the bottom left and not move at all. In all forums and questions, the answer is always “add a CanvasLayer” and then add the joystick scene inside it.

When I do this, nothing happens and the joystick is not visible at all. On the other hand, if I put the joystick inside the player, it works:

image

… Well, it works perfectly under one condition: I do not activate “Position smoothing”. If I activate it, you can immediately see the result here.

image

I tried this too:

image

If I un-check it, it works flawlessly. So there might be a bug where the “Position smoothing” is calculated after everything else including children positionning (or something like that).

You can get all my source code here.

Add your user controls as children of your main scene, not as children of your player.

I’ve done that and it cant work because it wont follow the player.

You need to learn about UI and HUDs.

Here is a great resource that gives a beginner’s level deep dive into it.