Double Jump
A double jump lets the character jump again in mid-air. Count the air jumps, use one per press and fill the count up again on landing. Set the upward speed instead of adding to it, so the jump feels the same rising or falling and fast presses cannot launch the character into the sky.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Double Jump" to my game.
What it should do: A second jump gives the player control in the air: a way to fix a misjudged jump, reach further or recover from a fall.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> ground
ground: On the ground
ready: Air jump left
spent: None left
ground --> ready: jumps or walks off
ground --> spent: press while walking off
ready --> ready: air jump, more left
ready --> spent: last air jump
ready --> ground: lands
spent --> spent: press does nothing
spent --> ground: lands
```
Use these starting values:
- airJumps: 1
- jumpSpeed: 12 units/s
- airJumpSpeed: 10 units/s
- gravity: 32 units/s²
- maxFallSpeed: 20 units/s
Watch out for these common mistakes:
- The air jump adds to the speed: Tell your AI: set the speed to the air jump speed, never add to it.
- Walking off a ledge: Tell your AI: fill up the air jumps on the ground, not on the jump, and decide if a fall uses one up. Here it does not.
- A late press near a ledge: Tell your AI: look at coyote time before the air jump.
- Landing and pressing at the same moment: Tell your AI: handle the landing while moving the character, and decide on jumps from where the character was when that step started.
Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
What it does
A second jump gives the player control in the air: a way to fix a misjudged jump, reach further or recover from a fall.
How it runs, as a diagram
Everything it can be in, and what moves it on. Your AI builds from exactly this.
How it runs, as a diagram
- On the ground → Air jump left: jumps or walks off
- On the ground → None left: press while walking off
- Air jump left → Air jump left: air jump, more left
- Air jump left → None left: last air jump
- Air jump left → On the ground: lands
- None left → None left: press does nothing
- None left → On the ground: lands
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| airJumps | 1 | How many jumps the character has in the air. Zero turns it off. |
| jumpSpeed | 12 units/s | How hard the character pushes off from the ground. |
| airJumpSpeed | 10 units/s | How hard the air jump pushes. A little under the ground jump keeps the ground jump the stronger one. |
| gravity | 32 units/s² | How fast a rise slows down. |
| maxFallSpeed | 20 units/s | The fastest the character can fall, and so the worst fall an air jump has to recover from. |
What usually goes wrong
The air jump adds to the speed
An air jump that adds to the speed is weak in a fall and huge on the way up, and fast presses launch the character into the sky.
Fix: Tell your AI: set the speed to the air jump speed, never add to it.
Walking off a ledge
If the air jumps only come back after a ground jump, a character that walks off a ledge has none left, or one too many, depending on how it was built.
Fix: Tell your AI: fill up the air jumps on the ground, not on the jump, and decide if a fall uses one up. Here it does not.
A late press near a ledge
With coyote time, a press just after a ledge uses up the air jump although it was meant as the ground jump.
Fix: Tell your AI: look at coyote time before the air jump.
Landing and pressing at the same moment
A press at the moment of landing can count as an air jump if the game decides on the air jump before the landing.
Fix: Tell your AI: handle the landing while moving the character, and decide on jumps from where the character was when that step started.
How to check it works
- Your character stands on the ground. Press jump: The character jumps and still has all its air jumps.
- Your character is falling with an air jump left. Press jump: The character rises again and has one air jump less.
- Your character is falling with no air jump left. Press jump: The character keeps falling.
- Your character has an air jump left. Try the air jump once while falling fast and once while still rising: Both times it gives the same speed.
- Your character has used up all its air jumps. Land: All air jumps are back.
- Your character walks off a ledge. Stay in the air without pressing anything: All air jumps are still there.
- Air jumps are set to zero. Press jump in the air: Nothing happens.
Works well with
- Coyote Time: Otherwise a late press uses up the air jump. Let coyote time go first, before the air jump.
- Variable-Height Jump: An air jump can be shortened too. A fixed air jump is easier to judge, a shortened one gives more control.
Clashes with Jump Buffering: A press in the air can mean an air jump now or a remembered jump on landing. Use the air jump first, and remember the press only when none is left.
Common questions
what do i tell my ai to add a double jump
Paste this: Add a double jump: give the character one air jump, use it up on a press in the air, set the upward speed instead of adding to it, and fill it up again on landing.
should a double jump add to velocity or set it
Set it. Adding makes the jump weak in a fall and huge while rising, and lets fast presses launch the character into the sky.
should a double jump be weaker than the first jump
Usually a little. A start of about five sixths of the ground jump's speed keeps the ground jump the main one while the air jump still rescues a fall.
does walking off a ledge use up the double jump
That is your choice. Here it does not: the character keeps its air jump, which feels more forgiving. To use it up, take one off the count when the character leaves the ground without a jump.
Where it comes from
Earliest example we could find: Dragon Buster (Namco, arcade) (1984). Game Informer, Guinness World Records and Destructoid all connect the double jump with this game, in which the hero Clovis jumps again in mid-air. The year follows Guinness (December 1984) and the Arcade Archives release text (1984). Game Informer says 1985, and Wikipedia gives January 1985 for Japan. No contemporary or developer source for the mechanic was found.
- 1984 Dragon Buster (Namco, arcade): Game Informer, Guinness World Records and Destructoid all connect the double jump with this game, in which the hero Clovis jumps again in mid-air. The year follows Guinness (December 1984) and the Arcade Archives release text (1984). Game Informer says 1985, and Wikipedia gives January 1985 for Japan. No contemporary or developer source for the mechanic was found. [First videogame to use the "double jump" (Guinness World Records)][An Ode To The Most Important Power-Up: Double Jump (Ben Reeves, Game Informer, 2014-11-04)][Announcing the release date of Arcade Archives DRAGON BUSTER (press release on Game Developer, 2021-12-09)][Relive the dawn of dungeon crawling with Arcade Archives' Dragon Buster (Chris Moyse, Destructoid, 2021-12-12)]
- 1984 Super Mario Bros. test version (Nintendo, internal): In Iwata Asks, Miyamoto recalls asking for a test version around December 1984 in which repeated button presses made Mario jump in the air as well. This was an unreleased experiment, and the source does not call it a double jump. It shows the idea being tried elsewhere at about the same time, not a link to Dragon Buster. It is the only developer statement on repeated mid-air jumping found for this period. [Iwata Asks: Super Mario Bros. 25th Anniversary, Vol. 5: Original Super Mario Developers, 1. Using the D-pad to Jump (Nintendo)]
- 1991 Super Ghouls 'n Ghosts (Capcom, Super Nintendo): Nintendo Life credits this game with popularising the double jump and says its level design is built around the move. A second press during a jump launches Arthur again. The Game Informer writer also names it as where he met the ability. The popularising claim is the reviewer's judgement. [Super Ghouls 'n Ghosts Review (Damien McFerran, Nintendo Life, 2013-05-23)][An Ode To The Most Important Power-Up: Double Jump (Ben Reeves, Game Informer, 2014-11-04)]
- 2014 Ben Reeves, 'An Ode To The Most Important Power-Up: Double Jump' (Game Informer): A trade-press essay traces the double jump from platformers into action games and shooters, naming Super Smash Bros., Castlevania: Symphony of the Night, Titanfall and Unreal Tournament. It is a personal appreciation rather than a researched history, and the only year it gives is for Dragon Buster. [An Ode To The Most Important Power-Up: Double Jump (Ben Reeves, Game Informer, 2014-11-04)]
- 2019 The Messenger (Sabotage), 'Cloudstep', Game Design Deep Dive: A developer account of reworking the mechanic: instead of a fixed extra jump, the player regains jumps in the air by landing attacks. The article presents this as a twist on the established double jump, which shows the mechanic was by then a convention that designers vary. The year is the article's date. [Game Design Deep Dive: Re-imagining the double jump in The Messenger (Game Developer, 2019-05-23)]
What was checked
- 10 tests pass on the reference code.
- The state diagram was checked against the code, at the default values and at every listed low and high value.
- The Godot port passes the same tests on the real engine.
Your AI gets the code
Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it