Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+6 votes

I want to be able to run by double pressing the same key I use to walk (think minecraft run)

asked in CSC380Jan2024 by (2k points)

6 Answers

+2 votes
 
Best answer

If you are using something that is an event you can call it in an if function

if event is InputEvent-whatever your button is and event.doubleclick:
answered by (2.4k points)
selected by
+4 votes

I haven't, but I programmed a double jump using the spacebar to double tap. So what I would recommend is something like having a boolean checking to see if player is walking, a timer to give the user time to active the run, and if both are true then the user gets to run. Though setting the run to a set key would be an idea if you can't get it to work.

answered by (2k points)
+4 votes

yea the 3d platformer kit has a double jump coded in if you wanna look at that and copy it

answered by (3.8k points)
+2 votes

You can additionally track the time elapsed between when it was clicked last and if it's within a short period of time you can change speeds that way

answered by (2.1k points)
+2 votes

There is a source on how to use the timer: https://godotforums.org/d/35106-is-there-a-simple-solution-for-a-double-tap

But I think double click would be easier to implant since there is a event.doubleclick method.

answered by (2.6k points)
0 votes

Use a timer node and if the action is pressed twice within the time then maker the player run, obviously when it timesout then the player won't double run.

answered by (2k points)
...