Spielerando

Sprint

Holding a button while moving makes the character run faster than it walks. Speed builds up and fades at set rates instead of jumping. The button does nothing without a direction, a wall or a tired body ends the sprint, and the sprint speed is a multiple of the walking speed so it is always faster.

Also called: Run, Dash run, Hold to run.

A clay armadillo messenger in a teal vest sprints along a winding pink road, leaning forward with a trail of dust and fading ghost copies behind it, while a snail with a flowerpot shell plods by the roadside.
Thumbprint Express, an invented clay courier game. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Sprint" to my game.

What it should do: A sprint lets the player choose between careful and fast movement. It adds a second gear to the same controls, so the player decides when speed is worth it.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> still
  still: Standing
  walk: Walking
  sprint: Sprinting
  slowing: Slowing down
  still --> walk: starts walking
  still --> sprint: starts sprinting
  walk --> still: comes to a stop
  walk --> sprint: sprint pressed
  sprint --> slowing: let go while fast
  sprint --> walk: let go while slow
  sprint --> still: wall or stops dead
  slowing --> sprint: sprint again
  slowing --> walk: slows to walk speed
  slowing --> still: wall or stops dead
```

Use these starting values:
- walkSpeed: 4 units/s
- sprintBoost: 1.75
- accel: 24 units/s²
- decel: 30 units/s²

Watch out for these common mistakes:
- The button pressed before moving: Tell your AI: look at the button and the direction on every tick, so that holding the button first and moving second sprints as well.
- Sprinting while standing still: Tell your AI: the sprint button counts only together with a direction.
- Speed that snaps back: Tell your AI: slow down at a set rate toward the walking speed instead of setting it.
- Turning around at full speed: Tell your AI: when the direction reverses, brake through zero at the slowing rate before building up the other way.
- Sprinting into a wall: Tell your AI: when the character is pushed against a wall, set the speed to zero and end the sprint.
- Starting or stopping a sprint in the air: Tell your AI: in the air keep the speed and change nothing. The button counts again on landing.
- A sprint that is not faster: Tell your AI: define the sprint speed as the walking speed times a factor above one.

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 sprint lets the player choose between careful and fast movement. It adds a second gear to the same controls, so the player decides when speed is worth it.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

starts walkingstarts sprintingcomes to a stopsprint pressedlet go while fastlet go while slowwall or stops deadsprint againslows to walk speedwall or stops deadStandingWalkingSprintingSlowing down
How it runs, as a diagram
  • Standing → Walking: starts walking
  • Standing → Sprinting: starts sprinting
  • Walking → Standing: comes to a stop
  • Walking → Sprinting: sprint pressed
  • Sprinting → Slowing down: let go while fast
  • Sprinting → Walking: let go while slow
  • Sprinting → Standing: wall or stops dead
  • Slowing down → Sprinting: sprint again
  • Slowing down → Walking: slows to walk speed
  • Slowing down → Standing: wall or stops dead

Good starting values

ValueStart withWhat it changes
walkSpeed4 units/sThe speed of walking. About two body lengths per second reads as a calm walk.
sprintBoost1.75The sprint speed as a multiple of the walking speed, so the sprint is always faster. Below 1.5 players barely notice, above 2.5 the level can no longer keep up.
accel24 units/s²How fast speed builds up. At this value a sprint from standing takes about 0.3 seconds, quick enough to feel direct and slow enough to feel like effort.
decel30 units/s²How fast speed falls when the player lets go, slows or turns. A little above the build-up, so stopping feels firmer than starting.

What usually goes wrong

The button pressed before moving

A player who holds the sprint button and then pushes a direction gets walking speed, because the game only looked at the button at the moment it was pressed.

Fix: Tell your AI: look at the button and the direction on every tick, so that holding the button first and moving second sprints as well.

Sprinting while standing still

A sprint that counts as running with no direction wastes a stamina meter, plays the running animation on the spot or gives a burst on the first step.

Fix: Tell your AI: the sprint button counts only together with a direction.

Speed that snaps back

If letting go of the button drops the speed to walking at once, the character jerks to a stop in the middle of a run.

Fix: Tell your AI: slow down at a set rate toward the walking speed instead of setting it.

Turning around at full speed

If the speed flips its sign in one tick, a sprinting character reverses instantly and the sprint has no weight.

Fix: Tell your AI: when the direction reverses, brake through zero at the slowing rate before building up the other way.

Sprinting into a wall

The player runs against a wall holding the button, the character stands still but is still counted as sprinting, and a stamina meter keeps draining for nothing.

Fix: Tell your AI: when the character is pushed against a wall, set the speed to zero and end the sprint.

Starting or stopping a sprint in the air

A sprint started in the air gives speed from nowhere, and letting go in the air stops the character in mid-flight. Both break jumps.

Fix: Tell your AI: in the air keep the speed and change nothing. The button counts again on landing.

A sprint that is not faster

When the sprint speed and the walking speed are set separately, a change to one can leave the sprint slower than the walk.

Fix: Tell your AI: define the sprint speed as the walking speed times a factor above one.

How to check it works

Works well with

Clashes with Coyote Time: A sprint off a ledge with a late jump press carries a lot of speed, so the grace time makes the jump much longer than a standing one. Allow the late jump, but plan gaps for the longest jump a sprint plus grace time can make.

Common questions

what do i tell my ai to add a sprint

Paste this: Add a sprint. Holding the button while pushing a direction moves the character at the walking speed times 1.75, speed builds and fades at set rates instead of jumping, the button does nothing without a direction, and a wall, a tired body or leaving the ground ends or freezes it.

how much faster should sprinting be than walking

Start at about three quarters faster. Under 50 percent faster most players do not notice it, over 150 percent faster and levels have to be built around it.

should the sprint be a toggle or a hold

Hold is easier to learn and cannot get stuck on. If you add a toggle, end it on a stop or a wall, or the player is still sprinting when they do not expect it.

why does my character keep sprinting against a wall

The sprint is decided by the button, not by whether the character really moves. Set the speed to zero and end the sprint when the character is pushed against a wall.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

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