I’m making a 2D game where you can make the camera move and zoom in and out. The camera has limits, so making the UI follow it is being a huge struggle with code only. Is there any convinient feature to not waste so much time coding the buttons following and scaling with the camera?
You should put your entire UI on the CanvasLayer node, so everything you have on the UI is under it.
I tried that. Not only did it not work (which maybe I could have fixed), but then clicking on a TouchArea did not work anymore. Maybe there’s a solution for that?
The official way of making UI is with the CanvasLayer and with Control nodes. Are you doing something else?
Are all of the assets in the same scene? I generally work in 3D and keep my 2D elements in different scenes. For example if I was making a roller coaster tycoon kind of game, I would have all of my UI buttons (build, destroy, settings, etc) in one scene, and then I would have another scene containing the 3D world and all of the logic relating to the 3D camera, that way the camera only moves around in the 3D space and the 2D elements stay on the screen how I place them.
Is that the kind of thing you are looking for? Or are you looking to do something differently?
Every button that should follow the camera is a children of the camera in one independent UI scene
Put the CanvasLayer at the root, it doesn’t need to be under the camera since the whole point of the CanvasLayer is that it’s independent. Without seeing too much of your node structure it’s hard to tell what might be wrong.
I solved it! I just went to the control node I had as the child of the CanvasLayer and changed “mouse_filter” to “Ignore”. Hope this helps someone in the future
You marked an answer that did not answer the title and the actual point of the thread you have created. And judging by your post history, you made a similar thread before and with an almost copy pasted answer to this one, you marked your own answer as the solution 3 times in a row.
Well, it was the solution to the problem I had. Is that something I should not do? In that case I won’t do it again, I’m sorry

