Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Godot 2d Controller?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-godot-2d-controller)
---
name: godot-2d-controller
description: >-
Move a 2D character in Godot: CharacterBody2D jump, coyote time, jump buffer, slopes, one-way
and moving platforms, top-down movement.
---
# godot-2d-controller — the motor that owns the position
One motor writes the position; the jump comes from an apex height and a time, not from tuned
constants. Everything else — sprites, sounds, the camera, a test — reads the motor and never
moves the body.
## Load what the situation needs
| The situation | Read |
|---|---|
| A side-view courier: run, jump, coyote time, jump buffer, a short hop | `resources/platformer_motor_2d.gd`, then `reference/platformer.md` |
| The jump falls short of the level; how wide a gap may be; jump numbers before levels | `reference/platformer.md` → "Jump from numbers", and the probe below |
| Creeping on a slope, run/fall flicker walking downhill, a ramp that acts like a wall | `reference/platformer.md` → "Floors and slopes" |
| One-way ledges, dropping through, moving platforms | `reference/platformer.md` → "One-way platforms", "Moving platforms"; `resources/moving_platform_2d.gd` |
| Seen from above: eight directions, friction, sliding along walls, facing | `resources/topdown_motor_2d.gd`, then `reference/topdown.md` |
| The sprite should follow run, jump and fall | `resources/motor_sprite_bridge_2d.gd`; `reference/platformer.md` → "Bridge to sprites" |
| A courier on a rooftop to play right now | `templates/courier_2d.tscn` |
| Collision layers, tunnelling, a ray that misses | `godot-physics` |
| Input actions, rebinding, touch | `godot-input` |
| `SpriteFrames` from a frame set; pixel-art import | `godot-2d-sprites` |
| Animation trees and state machines | `godot-animation` |
| The tiles the courier runs on | `godot-tilemap` |
| A camera that follows, look-ahead, jitter | `godot-camera` |
| Which genre this is; level metrics; journeys an agent can replay | `godot-gameplay` · `godot-play-harness` |
## The motor contract
Copy `resources/platformer_motor_2d.gd` (or `topdown_motor_2d.gd`) onto the courier's
`CharacterBody2D`. No `class_name`: attach it, or `preload()` it.
| Part | Platformer | Top-down |
|---|---|---|
| intent, set by gameplay or a test | `move_axis` (-1..1), `jump_held`, `press_jump()`, `release_jump()`, `press_drop()` | `move_vector` (length 0..1) |
| intent from input | `read_input` on: `action_left`, `action_right`, `action_jump`, `action_down` | `read_input` on: four actions and `deadzone` |
| read-only state | `motion_state` (`idle` `run` `rise` `fall`) | `motion_state` (`idle` `walk`), `facing` |
| signals | `jumped`, `landed`, `left_floor`, `state_changed` | `state_changed`, `facing_changed` |
| tunables | every number is an `@export`, grouped Run, Jump, Floor, One-way, Input | `max_speed`, `accel`, `friction`, `eight_way` |
The actions default to the built-in `ui_left`, `ui_right`, `ui_accept` and `ui_down` (and
`ui_up`), which every project has; replace them with the game's own actions. An action missing
from the `InputMap` reads as released, with no error. With `read_input` on the motor overwrites
the intent every tick: turn it off when gameplay, an AI or a journey writes the intent, or there
are two writers.
## Jump from numbers
Set `jump_height`, `time_to_apex` and `time_to_land`; the motor derives take-off speed
`2h / t_apex`, rise gravity `2h / t_apex^2` and fall gravity `2h / t_land^2`. Then measure what
the motor actually does, because a fixed step lands about `v0 * dt / 2` short (68.8 px of an asked
72 at 60 Hz):
```bash
python3 scripts/motor_probe_2d.py --jump-height 72 --time-to-apex 0.36 --reach 120,0 --reach 96,48 --miss 200,0
```
## Probe the motor
`scripts/motor_probe_2d.py` builds each level in code in a throwaway project outside the
repository, runs the motor headless at a fixed 60 Hz, records every tick and judges the
trajectory. Each scenario runs in its own `World2D`, so none sees another's bodies.
```bash
python3 scripts/motor_probe_2d.py # the shipped platformer motor
python3 scripts/motor_probe_2d.py --motor path/to/courier_motor.gd --set coyote_time=0.08
python3 scripts/motor_probe_2d.py --kind topdown --set friction=600
python3 scripts/motor_probe_2d.py --selftest
```
| Check | Holds when |
|---|---|
| lands, apex, hop | the courier rests on the floor; the apex is within 8% of `jump_height`; a one-tick tap rises less than half |
| coyote-in, coyote-out | a press half the window after walking off a ledge jumps; three ticks past it, none |
| buffer-in, buffer-out | the same for a press before landing; the jump fires on the tick after touch-down |
| slope-rest, slope-climb, slope-descend | no drift at rest on 30 degrees; walks up it; stays on the floor walking down |
| one-way-up, drop-through | jumps up through a one-way ledge and stands on it; `press_drop()` falls back through |
| moving-platform | carried within 1 px of the platform's displacement |
| input, bridge | the actions drive the motor; the sprite plays every state and flips running left |
| reach / miss GAP,RISE | the full-speed jump lands on, or misses, a ledge GAP px away and RISE px up |
| td-axis, td-diagonal, td-stop, td-wall, td-input, td-facing | top speed, no diagonal speed-up, the stopping distance, wall sliding, the actions, eight-way facing |
The last line is the verdict, `motor_probe_2d: PASS|FAIL|UNVERIFIED ...`: exit 0, 2 (a check
failed, each on a `FAIL` line), 3 (no Godot, a timeout, no sentinel: nothing was judged), 1 a
usage error. An engine or script error in the run is a `FAIL engine` line, never a pass. Godot
comes from `--godot PATH` or `GODOT_BIN`. The `--motor` script must keep the intent API above
and is run with `read_input` off.
## Discipline
- **One writer.** The motor calls `move_and_slide()` and nothing else sets `position` or
`velocity` on the courier: not an `AnimationPlayer` track, not a knockback script, not a
camera. A dash or a knockback is a state inside the motor.
- **Numbers before levels.** Fix the jump, probe it, then draw the level from the probe's reach;
a level drawn first decides the jump by accident.
- **Floor settings are level settings.** `floor_max_angle` comes from the steepest slope in the
levels and `floor_snap_length` from the run speed (`auto_snap` does the second); probe both
against the real slope before tuning anything else.
- **Physics tick, not frame.** Movement runs in `_physics_process`; a probe or a journey counts
ticks. A window in seconds is a window in ticks at the project's
`physics/common/physics_ticks_per_second`.
- **Presentation reads.** Sprites, particles and sound subscribe to the motor's signals and
`motion_state`; they never decide whether the courier is on the floor.