How to detect multiple mobile inputs at the same time with Godot?

Viewed 606

In the game I am currently making, the player will frequently need to press two buttons at the same time, for example "jump" and "left". Currently I have two buttons on the left side of the screen for left and right, and one on the right for jump. The problem is, if the player is pressing any of them, it effectively locks the other buttons, making it so you can't press them.

Is there some way, perhaps using InputEventScreenTouch, that I can detect the user's current touchscreen input every frame, and check if they are pressing one or more buttons?

Edit for more info: Currently each button sends it's button_down() and button_up() signals to the same function in the HUD scene root, and I have simple functions to handle that:

func setLeft(val):
    # This is the variable that the player
    # checks each frame to see if it should move
    self.get_parent().get_parent().goingLeft = val

So when the player starts pressing the left button, it sets goingLeft to true, and when they release it it sets goingLeft to false.

This should work fine, but I have discovered that if the player is touching the screen anywhere else, the buttons don't register input. For example, if I press the left button, the player starts going left, and then while I am holding that, I start pressing jump. The jump button doesn't register, because my finger is already pressing somewhere else on the screen (the left one).

It doesn't seem to matter if it is a button that I am pressing, just that Godot will only check buttons if there is exactly one input.

Is there some way to get around this?

1 Answers

I have found the solution, thanks to some people in the comments!

I changed the button types to TouchScreenButton nodes, and they have multitouch enabled, so I can press more than one at once, on a mobile device!

Related