Ladder Climbing
On a ladder, gravity stops and the character moves up and down at a steady speed. Grab only when the player presses up or down, never just for touching it. Slide the character onto the middle, step off at both ends, and give a jump off the ladder a short wait before it can grab 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 "Ladder Climbing" to my game.
What it should do: A ladder joins levels vertically without a jump. It must feel safe to grab, easy to leave, and never trap the character or catch it again by accident.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> free
free: Off the ladder
climbing: Climbing
hanging: Hanging still
leaping: Jumped off
free --> climbing: presses up or down
climbing --> hanging: stops pressing
hanging --> climbing: presses up or down
climbing --> free: reaches an end
hanging --> free: ladder gone or end
climbing --> leaping: jumps off
hanging --> leaping: jumps off
leaping --> free: wait is over
```
Use these starting values:
- climbSpeed: 3 units/s
- snapSpeed: 10 units/s
- jumpOffSpeed: 5 units/s
- jumpOffUp: 4 units/s
- regrabLock: 0.25 s
Watch out for these common mistakes:
- Walking past a ladder: Tell your AI: grab only when the player presses up or down while touching the ladder, never from touching alone.
- The ladder ends under the character's feet: Tell your AI: when the next step would pass the top or the bottom, let go and stand exactly at that end.
- Climbing down from a platform: Tell your AI: when the character stands at the top, pressing down grabs the ladder. Pressing up there does not.
- Jumping off and grabbing again: Tell your AI: after a jump off, ignore the ladder for a short wait, long enough to get clear.
- A sudden jump to the middle: Tell your AI: slide it toward the middle at a set speed, and stop exactly at the middle without passing it.
- The ladder disappears: Tell your AI: check every tick that the ladder is still there, and let go if it is not.
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 ladder joins levels vertically without a jump. It must feel safe to grab, easy to leave, and never trap the character or catch it again by accident.
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
- Off the ladder → Climbing: presses up or down
- Climbing → Hanging still: stops pressing
- Hanging still → Climbing: presses up or down
- Climbing → Off the ladder: reaches an end
- Hanging still → Off the ladder: ladder gone or end
- Climbing → Jumped off: jumps off
- Hanging still → Jumped off: jumps off
- Jumped off → Off the ladder: wait is over
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| climbSpeed | 3 units/s | How fast the character moves along the ladder. About half of walking speed: climbing should feel like effort but should not drag. |
| snapSpeed | 10 units/s | How fast the character slides onto the ladder's middle. Quick enough to be done in a few frames, slow enough that it does not look like a jump. |
| jumpOffSpeed | 5 units/s | The sideways push of a jump off. It must carry the character clear of the ladder's width. |
| jumpOffUp | 4 units/s | The upward push of a jump off. Lower than a ground jump, so leaving a ladder is a hop and not a leap. |
| regrabLock | 0.25 s | The wait after a jump off before the ladder can be grabbed again. It must be long enough for the character to move away, or the same key press catches the ladder at once. |
What usually goes wrong
Walking past a ladder
If touching a ladder grabs it, a player who only walks past gets pulled onto it. This is the most common complaint about ladders.
Fix: Tell your AI: grab only when the player presses up or down while touching the ladder, never from touching alone.
The ladder ends under the character's feet
At the top the character hovers over the platform, climbs into it, or keeps climbing on nothing. At the bottom it sinks into the floor.
Fix: Tell your AI: when the next step would pass the top or the bottom, let go and stand exactly at that end.
Climbing down from a platform
At the top edge the ladder is under the character's feet. If the grab needs the character to be below the top, the player cannot climb down and has to jump.
Fix: Tell your AI: when the character stands at the top, pressing down grabs the ladder. Pressing up there does not.
Jumping off and grabbing again
The player jumps off and still holds up, so the ladder catches the character on the very next tick and the jump goes nowhere.
Fix: Tell your AI: after a jump off, ignore the ladder for a short wait, long enough to get clear.
A sudden jump to the middle
Moving the character onto the ladder's middle in one step makes it pop sideways, and on a wide ladder that looks like teleporting.
Fix: Tell your AI: slide it toward the middle at a set speed, and stop exactly at the middle without passing it.
The ladder disappears
A ladder that is removed, broken or left behind by a moving platform keeps the character in a climb with nothing to hold on to.
Fix: Tell your AI: check every tick that the ladder is still there, and let go if it is not.
How to check it works
- Your character walks along a ladder and presses nothing up or down. A tick passes: The character is not on the ladder.
- Your character stands next to a ladder, 1 unit up. Press up: The character is on the ladder and has moved 0.05 up.
- Your character is at the bottom of a ladder. Hold up for one second: The character has climbed 3 units.
- Your character climbs for one second. Run it once at 30, once at 60 and once at 240 frames per second: It climbs 3 units every time.
- Your character is half a unit to the side of the ladder. Grab and keep climbing: It slides to the middle and stops exactly there, never past it.
- Your character is climbing. Let go of up and down: It hangs where it is and does not fall.
- Your character is just below the top of the ladder. Hold up: It lets go and stands exactly at the top.
- Your character is just above the bottom of the ladder. Hold down: It lets go and stands exactly at the bottom.
- Your character stands at the top of a ladder. Press down: It grabs the ladder and starts climbing down.
- Your character stands at the bottom, or at the top. Press down at the bottom, or up at the top: It does not grab the ladder.
- Your character is climbing. Jump while pressing left: It leaves the ladder with a push of 5 to the left and 4 up, and the grab wait starts.
- Your character hangs on the ladder. Jump without pressing a direction: It gets no sideways push and 4 up.
- Your character just jumped off and the player still holds up. Wait through the grab wait: It does not grab during the quarter second, and grabs on the next tick after.
- Your character is climbing. The ladder is gone: The character lets go.
- Your character is on the ground next to a ladder. Press jump: This code gives no push, the game's own jump handles it.
Works well with
- Coyote Time: Do not start the grace time when the character steps off an end onto solid ground. It is on the ground. Do start it after stepping off the side.
- Stamina System: If climbing costs stamina, hang still without cost and let the character slip down or let go when the meter is empty. Check the meter first, then climb.
Clashes with Jump Buffering: A jump pressed just before grabbing a ladder is remembered and fires the moment the character lands somewhere, or jumps off the ladder it just grabbed. Clear the remembered jump when the character grabs a ladder.
Common questions
what do i tell my ai to add ladders
Paste this: Add ladders. The character grabs a ladder only when the player presses up or down next to it, slides to the middle, climbs at a steady speed without gravity, steps off at the top and bottom, and a jump off pushes away with a short wait before it can grab again.
why does my character grab every ladder it walks past
The grab starts from touching alone. Change it so the grab needs a press of up or down, and so a press toward the end the character is standing at does nothing.
how fast should climbing be
About half the walking speed. Faster makes ladders a cheap shortcut, and much slower makes players avoid them. Make it the same up and down unless you want climbing down to feel like a slide.
should a character be able to jump off a ladder
Yes, with a small push away and a short wait before it can grab again. A jump that goes straight up from the ladder is fine, but without the wait the character just catches the ladder again.
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