+1 vote

I use the Kinematic Character demo to test the Godot engine at Android. I have modified the player with a CanvasLayer. This Layer has 4 TextureButtons to move, jump and go back to the menu.
At the player script i have changed this 3 lines

var walk_left = Input.is_action_pressed("ui_left")
var walk_right = Input.is_action_pressed("ui_right")
var jump = Input.is_action_pressed("ui_accept")

to this 3 lines

var walk_left = get_node("CanvasLayer/left").is_pressed()
var walk_right = get_node("CanvasLayer/right").is_pressed()
var jump = get_node("CanvasLayer/jump").is_pressed()

The problem is if I test the program at my phone, only one Button works. I can't walk and jump at the same time. if i push the left Button the other Buttons dosn't react.
If I push the jump button it is the same. The left or right button dosn't react.
I can't use more then one button.
If I use one Button the other Buttons are dead.
How can i make it that the jump and walk buttons work at the same time.

in Engine by (28 points)
recategorized by

Have you tried with TouchScreenButton instead?

Strange way of doing it.

Try a bunch of if's in Input process or Fixed process. I assume only one line of your code executes every time, so you can't get more than one input every iteration. Is also easier to leave out controls that exclude each other with loops like that:

if -> "move right"
elif -> "move left"
if -> "move up"
elif -> "move down"

The if statements will capture input at the same time, while elif only happens if the preceding if is false (so you don't get left and right at the same time, for instance).

I did a quick platformer to test Android deployment, I can share it with you if you want. It's a bit ugly and looks kinda stupid, but it works. xD

1 Answer

0 votes

I had same problem try to change button to touchscreen button :) should help :)

by (21 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.