Charge Jump
A charge jump lets the player decide how high to jump by how long they hold the button. A quick tap gives a small hop, a full hold gives the biggest jump, and letting go fires it. Count the hold in seconds, cap it at full, and lose it when the ground ends.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Charge Jump" to my game.
What it should do: A jump the player shapes with the button itself: a tap for a small hop, a long hold for a big leap. It makes a jump a decision, because a big one costs time before it starts.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> ready
ready: Ready
charging: Charging
full: Fully charged
air: In the air
ready --> charging: presses and holds
ready --> air: taps or walks off
charging --> full: charge fills up
charging --> ready: charge is cancelled
charging --> air: lets go or ground ends
full --> ready: charge is cancelled
full --> air: lets go or ground ends
air --> ready: lands
```
Use these starting values:
- minJumpSpeed: 6 units/s
- maxJumpSpeed: 16 units/s
- chargeTime: 0.6 s
- gravity: 32 units/s²
- maxFallSpeed: 20 units/s
Watch out for these common mistakes:
- The charge counts ticks: Tell your AI: add up the seconds the button is held, not the number of ticks.
- A tap does nothing: Tell your AI: the weakest jump is a real jump, with its own starting speed, never zero.
- Holding past full: Tell your AI: stop the charge at the full time and keep it there until the button is let go.
- A button held through a landing: Tell your AI: start a charge only from a fresh press on the ground, never from a button that was already down.
- The ground ends while charging: Tell your AI: throw the charge away the moment the character is no longer on the ground.
- The release that never comes: Tell your AI: give the game a way to cancel a charge, and use it whenever focus is lost or the character is hurt.
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 jump the player shapes with the button itself: a tap for a small hop, a long hold for a big leap. It makes a jump a decision, because a big one costs time before it starts.
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
- Ready → Charging: presses and holds
- Ready → In the air: taps or walks off
- Charging → Fully charged: charge fills up
- Charging → Ready: charge is cancelled
- Charging → In the air: lets go or ground ends
- Fully charged → Ready: charge is cancelled
- Fully charged → In the air: lets go or ground ends
- In the air → Ready: lands
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| minJumpSpeed | 6 units/s | The jump of a quick tap. Not zero, so a tap always does something. It stays under the full jump's lowest value, so the two can never swap places. |
| maxJumpSpeed | 16 units/s | The jump of a full hold, the highest the character can jump from the ground. Height grows faster than speed, so a quarter more speed is already about half as high again. |
| chargeTime | 0.6 s | How long the button must be held for the biggest jump. Around half a second feels like a decision. Much longer feels like waiting. |
| gravity | 32 units/s² | How fast a rise slows down. |
| maxFallSpeed | 20 units/s | The fastest the character can fall. |
What usually goes wrong
The charge counts ticks
A charge counted in ticks takes twice as long to fill on a game running at half the speed, so the same hold gives a different jump on every machine.
Fix: Tell your AI: add up the seconds the button is held, not the number of ticks.
A tap does nothing
If the jump grows from zero, a quick tap barely lifts the character and the button feels broken.
Fix: Tell your AI: the weakest jump is a real jump, with its own starting speed, never zero.
Holding past full
If the charge keeps growing after full, a long wait gives a jump far beyond what the level was built for.
Fix: Tell your AI: stop the charge at the full time and keep it there until the button is let go.
A button held through a landing
A player who keeps the button down in the air lands, and a game that only looks at the button's level starts a charge at once and then jumps again on release.
Fix: Tell your AI: start a charge only from a fresh press on the ground, never from a button that was already down.
The ground ends while charging
A character that slides off a ledge or whose floor drops away mid-charge keeps its charge and fires a jump from thin air when the button is let go.
Fix: Tell your AI: throw the charge away the moment the character is no longer on the ground.
The release that never comes
If the window loses focus or the character is hit while charging, the game may never see the button go up, so the character stays crouched or fires a surprise jump later.
Fix: Tell your AI: give the game a way to cancel a charge, and use it whenever focus is lost or the character is hurt.
How to check it works
- Your character stands on the ground. Tap the button and let go at once: The character jumps with the tap speed.
- Your character stands on the ground. Hold the button for 0.2 seconds in one try and 0.4 seconds in another, then let go: The longer hold jumps faster than the short one, and both beat a tap.
- Your character stands on the ground. Hold the button for the full time and let go: The character jumps with the full speed.
- Your character stands on the ground. Hold the button for five seconds and let go: The jump is the same as a full charge.
- Your character stands on the ground. Keep the button down for five seconds: The character stays on the ground, with a full charge.
- Your character is charging. The floor drops away under it: The character falls and the charge is gone.
- Your character falls with the button already down. It lands and the button stays down, then is let go: No charge builds and no jump happens.
- Your character is in the air. Press the button: No charge starts and the character keeps falling.
- Your character is charging. The game cancels the charge, then the button is let go: The charge is gone and no jump happens.
Works well with
- Coyote Time: Without it a character that just left a ledge loses a charge it has built, which feels unfair. With it, a short grace can keep the charge for a moment. Let coyote time go first.
- Double Jump: A charged jump from the ground and a fixed jump in the air make a clear pair: the player plans the first and corrects with the second.
- Stamina System: A big jump can cost a part of the bar. Take it when the jump fires, and refuse a charge that the bar cannot pay for. Check the cost when the charge starts.
Clashes with Variable-Height Jump: Both let the player choose the height with the button. Together, a charge picks the height before the jump and a cut shortens it after, and the player cannot tell which one they are controlling. Pick one. If you want both, cut a charged jump only when it is a tap.
Clashes with Jump Buffering: A remembered press from the air would start a charge on landing, and the button is not even down any more. Turn a remembered press into a tap jump, never into a charge.
Common questions
how do i make a charge jump
Paste this: Add a charge jump: while the player holds the jump button on the ground, count the seconds up to a full time, and when the button is let go jump with a speed between a small tap jump and a big full jump. Lose the charge when the ground ends.
how long should a charge jump take to charge
Start with 0.6 seconds for the full charge. Around half a second feels like a choice, and under 0.3 seconds nobody can tell the middle jumps apart.
should a charge jump scale the speed or the height
Scale the speed. Height grows with the square of the speed, so scaling the speed in a straight line still gives a smooth rise in height, and the character always follows the same gravity.
can the player move while charging a jump
That is your choice. Standing still makes the charge a clear commitment. Letting the player walk makes it a tool for running jumps. This reference only covers the jump itself.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 17 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