# Godot 2d Movement

Implement 2D kinematic character movement in Godot 4.7 with CharacterBody2D and...

- Repository: https://github.com/gamedev-skills/awesome-gamedev-agent-skills (6445 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-28
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill godot-2d-movement -g -a claude-code -y`
Codex: `npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill godot-2d-movement -g -a codex -y`
Cursor: `npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill godot-2d-movement -g -a cursor -y`
Gemini CLI: `npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill godot-2d-movement -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add gamedev-skills/awesome-gamedev-agent-skills`

## Description

Implement 2D kinematic character movement in Godot 4.7 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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Godot 2D Movement (4.x)

Build responsive 2D character controllers with `CharacterBody2D` and the argument-less
`move_and_slide()`. Targets **Godot 4.7**.

## When to use

- Use when scripting a 2D player/enemy that moves and collides: platformer (gravity +
  jump) or top-down (free 8-direction), slope walking, or wall/floor detection.
- Use when `move_and_slide()` "does nothing", the character sinks through floors, or
  `is_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`.

## Core workflow

1. **Use `CharacterBody2D`** with a `CollisionShape2D` child. It is script-driven: it
   does not fall or react to forces on its own.
2. **Set the `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.
3. **Do it in `_physics_process(delta)`**, `move_and_slide()` uses the physics step's
   delta internally, so do not multiply `velocity` by `delta` yourself.
4. **Platformer:** add gravity to `velocity.y` each tick, jump by setting `velocity.y`
   negative when `is_on_floor()`.
5. **Top-down:** build a direction from input and scale by speed; set
   `motion_mode = MOTION_MODE_FLOATING` so there is no "floor/wall" distinction.
6. **Read results** with `is_on_floor()`, `is_on_wall()`, `get_wall_normal()`, and
   `get_slide_collision(i)` after the call.

## Patterns

### 1. Platformer controller (gravity, jump, slopes)

```gdscript
extends CharacterBody2D

@export var speed := 200.0
@export var jump_velocity := -400.0
@export var gravity := 1200.0          # pixels/sec^2 (tune to taste)

The rest: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/HEAD/skills/godot/godot-2d-movement/SKILL.md
