Glide
A glide turns a fall into a slow drift while the player holds the button. Start it only with a fresh press while falling, ease the fall down to the glide speed instead of snapping to it, and let only time spent gliding use up the glide time. Standing on the ground fills it up again.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Glide" to my game.
What it should do: A glide lets the player cross gaps that a jump cannot, and gives time to aim a landing. It rewards planning, and it forgives a jump that was a little too short.
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
air: In the air
glide: Gliding
spent: Glide used up
ground --> air: walks off an edge
air --> ground: lands
air --> glide: fresh press while falling
air --> spent: press uses the last time
glide --> air: button is released
glide --> spent: glide time runs out
glide --> ground: lands
spent --> ground: lands
```
Use these starting values:
- glideFall: 3 units/s
- brake: 90 units/s²
- glideTime: 2.5 s
- gravity: 32 units/s²
- maxFallSpeed: 20 units/s
Watch out for these common mistakes:
- Holding the jump button: Tell your AI: start a glide only on a fresh press in the air. A button held since the jump does not count.
- The glide sets the speed: Tell your AI: ease a faster fall down to the glide speed, and leave a slower fall to gravity until it reaches the glide speed.
- Letting go refills the time: Tell your AI: only the ground fills the glide time up. Letting go keeps what is left.
- A glide on the way up: Tell your AI: start a glide only when the character is falling or has stopped rising.
- The press on the edge: Tell your AI: let coyote time and the ground jump decide first, and start a glide only once the character is truly in the air.
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 glide lets the player cross gaps that a jump cannot, and gives time to aim a landing. It rewards planning, and it forgives a jump that was a little too short.
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 → In the air: walks off an edge
- In the air → On the ground: lands
- In the air → Gliding: fresh press while falling
- In the air → Glide used up: press uses the last time
- Gliding → In the air: button is released
- Gliding → Glide used up: glide time runs out
- Gliding → On the ground: lands
- Glide used up → On the ground: lands
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| glideFall | 3 units/s | The speed the fall settles at while gliding. About a seventh of the normal fastest fall: slow enough to feel like floating, fast enough that the glide still goes down. |
| brake | 90 units/s² | How fast a faster fall is eased down to the glide speed. From the normal fastest fall it takes about a fifth of a second, which is quick but not a hard stop. |
| glideTime | 2.5 s | How long one airtime may be spent gliding. At the starting values that carries the character about seven units down, enough to cross a gap but not to ignore it. |
| gravity | 32 units/s² | How fast a fall speeds up when not gliding. |
| maxFallSpeed | 20 units/s | The fastest the character can fall when not gliding. |
What usually goes wrong
Holding the jump button
If the glide starts whenever the button is down and the character is falling, every jump turns into a glide at the top, and the player can no longer fall on purpose.
Fix: Tell your AI: start a glide only on a fresh press in the air. A button held since the jump does not count.
The glide sets the speed
If the glide sets the fall speed to the glide speed, a fast fall stops dead as if it hit a wall, and a slower fall is sped up to the glide speed.
Fix: Tell your AI: ease a faster fall down to the glide speed, and leave a slower fall to gravity until it reaches the glide speed.
Letting go refills the time
If the glide time starts again whenever the button is released, a player who taps the button every second glides forever.
Fix: Tell your AI: only the ground fills the glide time up. Letting go keeps what is left.
A glide on the way up
A glide that can start while the character is still rising flattens the jump and throws the arc away.
Fix: Tell your AI: start a glide only when the character is falling or has stopped rising.
The press on the edge
A press on the tick the character steps off an edge is meant as a late jump, not as a glide. Reading it as a glide eats the jump.
Fix: Tell your AI: let coyote time and the ground jump decide first, and start a glide only once the character is truly in the air.
How to check it works
- Your character is falling. The player presses the button and keeps holding it: The fall settles at the glide speed and stays there.
- Your character is falling and the button has been held since before the fall. The player keeps holding it: The character falls normally.
- Your character is still rising. The player presses the button: The rise goes on as it would without the press.
- Your character falls at nearly its fastest. The player starts a glide: The fall slows over a fraction of a second and does not jump to the glide speed in one tick.
- Your character is gliding. The player lets go of the button: The glide ends and the fall speeds up again.
- Your character glides with the button held the whole time. The glide time is used up: The glide ends and the fall speeds up although the button is still down.
- Your character has used part of its glide time. It lands: The glide time is full again.
- Your character has glided for half a second. The player lets go and waits: The glide time stays where it was.
- Your character is gliding. A hundred ticks pass: The character never rises.
Works well with
- Variable-Height Jump: A short hop never reaches the point where a glide can start, which keeps small jumps small. Let the jump rise and end first, and start the glide only after the top.
- Stamina System: Stamina can replace the glide time, so one meter covers everything the character does in the air. Spend stamina while gliding and treat an empty bar like letting go.
- Coyote Time: A late press near an edge should be a jump, not a glide. Let coyote time decide first, then the glide.
Clashes with Double Jump: A press in the air can mean an air jump or the start of a glide, and both use the same button. Use the air jump on the press and start the glide on a second press or a hold after it. Or give the glide its own button.
Clashes with Ground Pound: Down in the air and a held button can both be asked for at once. Let the slam end the glide at once. It is the more committed move.
Common questions
what do i tell my ai to add a glide
Paste this: Add a glide: a fresh press of the jump button in the air, while the character is falling, starts a slow fall that lasts while the button is held. Ease a faster fall down to the glide speed, never lift the character, use up a glide time only while gliding, and fill it up again on the ground.
why does my character glide at the top of every jump
The glide probably starts whenever the button is down and the character is falling. Make it need a fresh press in the air, so a button held from the jump does nothing.
should a glide have a time limit
Usually yes, or a glide can replace the jump and make gaps and falls meaningless. A few seconds per airtime is a good start, filled up only on the ground.
can the glide use the same button as the double jump
It can, but the player must know which one a press means. Spend the air jumps first and start the glide on a press after they are gone, or give the glide its own button.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 18 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.
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