0 votes

To clarify I'm making a simple platform fighter (think Smash Bros) and I want to have the character walk and run using the same keys. I decided on making them run if the key is pressed quickly and walk if it's pressed slowly (the keys I'm using are A and D for left and right respectively). And thus we come back to the title question.

BTW I'm super new to this engine/ GDScript so I'd appreciate as much detail as you care to give. Thank you in advance.

in Engine by (15 points)

I don't think it's possible for a computer to know how fast you hit the button.

Indeed, all common keyboards out there have digital input, which means each key has an "all or nothing" strength. This is in contrast to gamepads or the elusive analog keyboards.

So like Krippi said. Just use something like double tap or even a shift button combined with walking to either run or walk.

Had a feeling this was the case, thanks for clarifying. I intend to have gamepad support as well so I just went with having a sprint key for keyboard.

1 Answer

+1 vote

I think you can't press a button quickly and slowly. But you can ask whether a button holds for 1 second and then let the player run instead of walk.

Or you do it with D = walk and double D = run. So a double click.

Do you mean this?

by (109 points)

If I went for something like this I would just have a run button to be held in conjunction as I don't like double tapping, thanks anyway.

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 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 webmaster@godotengine.org with your username.