Positioning TouchScreenButton without anchors

Godot Version

4.5.1

Question

I’m working on mobile controls in Godot 4 using TouchScreenButton.

Since TouchScreenButton inherits from Node2D, it doesn’t support anchors or Control layouts. I’m trying to place movement buttons (left/right) near the bottom-left and a jump button slightly inward from the bottom-right, in a way that scales correctly across different screen sizes and orientations.

Right now this requires manual viewport-relative positioning in a script.

Is this the intended / recommended approach in Godot 4, or is there a cleaner editor-based or engine-supported way to lay out TouchScreenButtons responsively without writing custom layout code?

Hello. TouchScreenButton created not for the player interface, but for the gameplay featuers.
Use TextureButton instead.

Please, read about TouchScreenButton and TextureButton in the offical docs.

OHH, but I need multitouch, essentially I need more than 1 buttons to be able to be pressed at once, which I dont think is possible with TextureButton.

Touch screen buttons are a little hard to use for my liking, I’ve gotten them to work as children of control nodes with similarly sized custom_minimum_size properties on the parent Control nodes

Here’s a link to my post implementing such a thing, I don’t think it’s a good solution, but I think it’s something the Godot engine needs to improve before users can do better (unless I’m wrong and I’d love to be wrong).

2 Likes

Ill take a look into it, tho your way seems like its held on HOPES AND PRAYERS but I’ve been tryna fix this shit for hours now and at this point I js hope it works ;-;

Yep. It’s one of problem at mobile development on Godot. But, as @gertkeno say, you can use Control node with anchor. Put TouchScreenButton to child of Control node and set up the anchors on it.

Read about that here.

You guys mean something like this right?

UPDATE I GOT IT TO FIX!!!