godot-2d-movement
БесплатноБез исполняемых скриптовНе проверенGodot 4.7 CharacterBody2D movement in GDScript: platformer run and jump, top-down 8-direction motion, slopes and one-way platforms, with a headless landing…
от gamedev-skills★ 12 656 звёзд на GitHubОб этом скилле
Godot 2D Movement (4.x)
Write CharacterBody2D controllers that land, run, jump and slide the way the engine expects,
then prove it with a headless test. Targets Godot 4.7; check config/features in
project.godot and keep an older project on its own version.
Workflow
- Read the scene first. Open the player
.tscn: the root should be aCharacterBody2Dwith aCollisionShape2D/CollisionPolygon2Dchild, and the action names the script uses must exist under[input]inproject.godot. - Pick the motion mode. Platformers keep the default
MOTION_MODE_GROUNDED; top-down games setMOTION_MODE_FLOATING, which has no floor or ceiling: every collision counts as a wall (is_on_wall(),get_wall_normal()), and slides keep a constant speed. - Set
velocity, then callmove_and_slide()once per_physics_process(). It takes no arguments, applies the physics delta itself, and writes back the velocity after collisions. - Read results after the call:
is_on_floor(),is_on_wall(),get_wall_normal(),get_slide_collision(i). They describe the lastmove_and_slide(), not the current frame. - Hand off feel. Coyote time, jump buffering, variable jump height and apex tuning belong
to
platformer; this skill supplies the Godot hooks they read (is_on_floor(),velocity). - Verify before you finish (paths are relative to this skill's folder):
- If
godot-nodes-scenesis installed, runpython3 ../godot-nodes-scenes/scripts/check_godot_project.py <project>after adding or moving scenes and scripts; fix everyERROR. - Copy
assets/test_character_controller.gdtores://tests/, set the action names at the top to the project's, and rungodot --headless --path <project> --script res://tests/test_character_controller.gd -- res://player.tscn. Exit 0 means the body landed, jumped and ran (or, floating, moved on both axes without drifting); eachFAILline names the behaviour that broke. On a fresh checkout rungodot --headless --path <project> --importfirst. To keep it in CI, usegodot-gdscript-headless-testing. - If the user wants feel signed off, ask them to play and report jump height and how fast the character stops; the test only proves the mechanics.
- If
Patterns
1. Platformer controller
extends CharacterBody2D
@export var speed := 200.0
@export var jump_velocity := -400.0
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta # project gravity plus any Area2D override
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_velocity
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) # stops within one tick
move_and_slide()
For a tunable fall speed that ignores the project setting, replace get_gravity() with an
exported Vector2(0, gravity). For weight, ramp with move_toward(velocity.x, dir * speed, accel * delta); the reference has the full version.
2. Top-down 8-direction movement
extends CharacterBody2D
@export var speed := 220.0
func _ready() -> void:
motion_mode = CharacterBody2D.MOTION_MODE_FLOATING
func _physics_process(_delta: float) -> void:
# get_vector applies the action deadzones and caps the length at 1.
velocity = Input.get_vector("move_left", "move_right", "move_up", "move_down") * speed
move_and_slide()
3. React to what the body touched
func _physics_process(delta: float) -> void:
# ... set velocity ...
move_and_slide()
for i in get_slide_collision_count():
var other := get_slide_collision(i).get_collider()
if other and other.is_in_group("enemies"):
take_damage(1)
Gotchas
- The character crawls →
velocitywas multiplied bydelta.move_and_slide()already scales by the physics step; onlymove_and_collide()takes a per-frame motion. is_on_floor()is always false → the body is inMOTION_MODE_FLOATING,up_directionis notVector2.UP, there is no collision shape, the floor's layer is not in this body's mask, ormove_and_slide()has not run yet this tick (it reports the last call).- It falls through the floor or teleports → code moves it with
position +=orglobal_position =, which skips collision. Move throughvelocityonly; teleport only for respawns. - Motion jitters or depends on frame rate → movement runs in
_process(). Use_physics_process(); for smooth visuals at high refresh rates turn onphysics/common/physics_interpolationrather than moving the body in_process(). - Sliding down slopes while idle → keep
floor_stop_on_slopeon (default) and raisefloor_snap_length(default 1 px) so the body sticks when walking downhill. Slopes ste
Установить godot-2d-movement в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл godot-2d-movement?
Godot 4.7 CharacterBody2D movement in GDScript: platformer run and jump, top-down 8-direction motion, slopes and one-way platforms, with a headless landing test. Use when a 2D controller will not move, falls through the floor or is_on_floor() is always false. Not for coyote time and jump feel (`platformer`), RigidBody2D, raycasts or 3D (`godot-physics`) or tile levels (`godot-tilemap`).
Как установить скилл godot-2d-movement?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл godot-2d-movement запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic