Is there a wait function in godot 4.2

Godot Version

4 2

Question

Is there a wait function like this:

If input.is action just pressed(jump):
Hold on to jump input for 1 second.
If is on floor and jump input is true
Velovity y = 2

So basicly if the player presses jump when he is just above the floor the script hold on to the info of jump pressed for 1 second and if in that 1 second timeframe he touches the floor it jump.

The way this is usually done is:

  • You have in your script a boolean variable called something like wants_to_jump
  • Whenever the player presses the jump button, you set wants_to_jump to True, and start a 1 second timer.
  • When that timer runs out, you set wants_to_jump to False
  • Every frame, if the player is touching the floor, you check if wants_to_jump is True, and if it is, you make the player jump, and also set wants_to_jump to False.

Thank you