This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+2 votes

I want to handle two inputs: left and right. But it seems that the _input
method from Node cant handle them.
So here is my scenario: When I press right my Character walks to the right; when I then press left (and keep right pressed) my Character walks to the left, which shouldn't happen since I press left and right and the movements should eliminate each other.

func _input(event):
if(event.is_action("move_left")):
    print("left")
    velocity.x -= WALK_SPEED
    #get_tree().set_input_as_handled()

if(event.is_action("move_right")):
    velocity.x += WALK_SPEED
    print("right")
    #get_tree().set_input_as_handled()

It seems like the _input method is only called for the last key pressed.
Is this normal? And how to get around this to have multiple inputs at once.

in Engine by (25 points)

1 Answer

+2 votes

Yes, it is normal.
Check my answer to this similar question: https://godotengine.org/qa/14790/input-detection-problem

by (29,510 points)

Thank you for your quick reply!

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.