Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement 2D kinematic character movement in Godot 4.x with CharacterBody2D and move_and_slide(): platformer run/jump with gravity, top-down 8-direction motion, slope handling, and reading collisions. Use when coding a 2D player or enemy controller, a platformer or top-down character, or fixing move_and_slide()/ is_on_floor() behavior in a .tscn with a CharacterBody2D.
.claude/skills/gamedev-skills-godot-2d-movement/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 102% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 58% | 0% |
| case-15 | ✓→✓ | = Same ✓ | 295% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 111% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 105% | 0% |
Build responsive 2D character controllers with CharacterBody2D and the argument-less move_and_slide(). Targets Godot 4.7.
jump) or top-down (free 8-direction), slope walking, or wall/floor detection.
move_and_slide() "does nothing", the character sinks through floors, oris_on_floor() is always false.
When not to use: dynamic rigid bodies, areas, raycasts, collision layers → godot-physics; tile-based levels → godot-tilemap; full platformer game template → the platformer genre skill; engine-agnostic feel tuning → physics-tuning.
CharacterBody2D with a CollisionShape2D child. It is script-driven: itdoes not fall or react to forces on its own.
velocity property, then call move_and_slide() (no arguments in 4.x).The method reads velocity, moves the body, slides along surfaces, and updates velocity to reflect what actually happened.
_physics_process(delta) — move_and_slide() uses the physics step'sdelta internally, so do not multiply velocity by delta yourself.
velocity.y each tick, jump by setting velocity.ynegative when is_on_floor().
motion_mode = MOTION_MODE_FLOATING so there is no "floor/wall" distinction.
is_on_floor(), is_on_wall(), get_wall_normal(), andget_slide_collision(i) after the call.
gdscriptextends CharacterBody2D @export var speed := 200.0 @export var jump_velocity := -400.0 @export var gravity := 1200.0 # pixels/sec^2 (tune to taste) func _physics_process(delta: float) -> void: # Apply gravity while airborne. if not is_on_floor(): velocity.y += gravity * delta # Jump only when grounded (Input action set in Project Settings > Input Map). if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = jump_velocity # Horizontal input: -1, 0, or 1. var dir := Input.get_axis("move_left", "move_right") if dir != 0.0: velocity.x = dir * speed else: velocity.x = move_toward(velocity.x, 0.0, speed) # decelerate to a stop move_and_slide() # 4.x: no arguments; uses and updates `velocity`
gdscriptextends CharacterBody2D @export var speed := 220.0 func _ready() -> void: motion_mode = CharacterBody2D.MOTION_MODE_FLOATING # no floor/ceiling concept func _physics_process(_delta: float) -> void: # get_vector returns a normalized-ish Vector2 from four input actions. var input := Input.get_vector("move_left", "move_right", "move_up", "move_down") velocity = input * speed move_and_slide()
gdscriptfunc _physics_process(delta: float) -> void: # ... set velocity ... move_and_slide() for i in get_slide_collision_count(): var c := get_slide_collision(i) var other := c.get_collider() if other and other.is_in_group("enemies"): take_damage(1) # touched an enemy while moving
gdscript@export var coyote_time := 0.1 var _coyote := 0.0 func _physics_process(delta: float) -> void: if not is_on_floor(): velocity.y += gravity * delta _coyote -= delta else: _coyote = coyote_time if Input.is_action_just_pressed("jump") and _coyote > 0.0: velocity.y = jump_velocity _coyote = 0.0 # ... horizontal input + move_and_slide() ...
move_and_slide(velocity) (returning the new velocity) wasremoved. In 4.x set the velocity property and call move_and_slide() with no args. move_and_slide(velocity, Vector2.UP) will not parse.
move_and_slide() already accounts for the physicsdelta. Setting velocity = dir * speed * delta makes the body crawl.
_process instead of _physics_process causes frame-rate-dependent,jittery motion. Always move in _physics_process.
is_on_floor() always false when up_direction is wrong (default Vector2.UP),there is no CollisionShape2D, or you never called move_and_slide() this frame.
floor body is on a layer this body's mask doesn't include, or you moved the body via position += instead of velocity + move_and_slide().
floor_stop_on_slope = true (default) and set afloor_snap_length so the body sticks to downward slopes.
move_and_collide() (manual collision response), read references/controller-recipes.md.
godot-physics — collision layers/masks, areas, raycasts, rigid bodies.godot-tilemap — building the levels this character walks on.godot-animation — driving sprite/skeletal animation from movement state.camera-systems — follow camera, deadzone, and look-ahead that track this character.platformer / input-systems — full genre template and rebindable input.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | pass→pass | 11,051 | 18,672 | +69% | 1 | 1 | 0% | 2,098 | 3,322 | +58% | 0 | 0 | — |
case-15 | pass→pass | 3,038 | 3,208 | +6% | 1 | 1 | 0% | 550 | 2,171 | +295% | 0 | 0 | — |
case-01 | fail→pass | 6,690 | 5,543 | -17% | 1 | 1 | 0% | 1,393 | 2,812 | +102% | 0 | 0 | — |
case-02 | pass→pass | 7,455 | 5,340 | -28% | 1 | 1 | 0% | 1,296 | 2,740 | +111% | 0 | 0 | — |
case-03 | pass→pass | 7,578 | 7,124 | -6% | 1 | 1 | 0% | 1,483 | 3,047 | +105% | 0 | 0 | — |
case-04 | pass→pass | 6,350 | 6,144 | -3% | 1 | 1 | 0% | 1,369 | 2,886 | +111% | 0 | 0 | — |
case-06 | pass→pass | 9,465 | 4,549 | -52% | 1 | 1 | 0% | 1,720 | 2,466 | +43% | 0 | 0 | — |
case-07 | pass→pass | 13,074 | 5,647 | -57% | 1 | 1 | 0% | 2,749 | 2,636 | -4% | 0 | 0 | — |
case-08 | pass→pass | 8,867 | 7,195 | -19% | 1 | 1 | 0% | 1,725 | 2,937 | +70% | 0 | 0 | — |
case-09 | pass→pass | 10,389 | 5,775 | -44% | 1 | 1 | 0% | 1,907 | 2,778 | +46% | 0 | 0 | — |
case-10 | pass→pass | 8,802 | 4,024 | -54% | 1 | 1 | 0% | 1,502 | 2,333 | +55% | 0 | 0 | — |
case-11 | pass→pass | 8,846 | 7,768 | -12% | 1 | 1 | 0% | 1,598 | 3,028 | +89% | 0 | 0 | — |
case-12 | pass→pass | 13,906 | 8,686 | -38% | 1 | 1 | 0% | 2,437 | 3,334 | +37% | 0 | 0 | — |
case-13 | pass→pass | 10,696 | 5,958 | -44% | 1 | 1 | 0% | 1,987 | 2,817 | +42% | 0 | 0 | — |
case-14 | pass→pass | 4,314 | 4,174 | -3% | 1 | 1 | 0% | 787 | 2,381 | +203% | 0 | 0 | — |
case-16 | pass→pass | 8,219 | 5,388 | -34% | 1 | 1 | 0% | 1,587 | 2,728 | +72% | 0 | 0 | — |
case-17 | pass→pass | 4,634 | 3,634 | -22% | 1 | 1 | 0% | 818 | 2,240 | +174% | 0 | 0 | — |
case-18 | pass→pass | 3,296 | 2,451 | -26% | 1 | 1 | 0% | 532 | 2,061 | +287% | 0 | 0 | — |
case-19 | pass→pass | 10,122 | 6,948 | -31% | 1 | 1 | 0% | 1,910 | 2,754 | +44% | 0 | 0 | — |
case-20 | pass→pass | 13,165 | 10,185 | -23% | 1 | 1 | 0% | 2,277 | 3,649 | +60% | 0 | 0 | — |
case-21 | pass→pass | 13,464 | 7,697 | -43% | 1 | 1 | 0% | 2,435 | 3,101 | +27% | 0 | 0 | — |
case-22 | pass→pass | 12,402 | 9,998 | -19% | 1 | 1 | 0% | 2,343 | 3,644 | +56% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 8/2/2026 | -33% |
Other measured skills in the registry, with their headline benchmark lift.