godot-2d-movement-sh-9v2tv8

A skill dedicated to Godot 2D Movement, to help an AI agent efficiently complete tasks related to Godot2dmovement.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "godot-2d-movement-sh-9v2tv8" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9872046b7548ba2032d9bb488be178bc17f9021970830025bd3ca014f46e8b88. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/godot-2d-movement-sh-9v2tv8 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

A skill dedicated to Godot 2D Movement, to help an AI agent efficiently complete tasks related to Godot2dmovement.

0 Downloads

Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference

SkillPi interpretation

Tasks
Build responsive 2D character controllers with `CharacterBody2D` and the argument-less `move_and_slide()`. Targets **Godot 4.3+**.
Audience
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`.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: Godot2dmovement
slug: godot-2d-movement
version: 1.0.0
displayName: Godot2dmovement
description: >
  Godot2dmovement专用技能,帮助AI Agent高效完成相关任务。
  Godot2dmovement专用技能,帮助AI Agent高效完成相关任务。
summary: "Godot2dmovement专用技能,帮助AI Agent高效完成相关任务。"
license: Apache-2.0
category: 游戏开发
framework:
  - Claude Code
  - Codex
  - Hermes Agent
  - OpenClaw
  - QClaw
  - WorkBuddy
platform: multi-platform
homepage: "https://github.com/1991513ccie-png"
repository: "https://github.com/1991513ccie-png"

Godot 2D Movement (4.x)

Build responsive 2D character controllers with CharacterBody2D and the argument-less move_and_slide(). Targets Godot 4.3+.

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)

extends 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`

2. Top-down 8-direction movement

extends 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()

3. Reading slide collisions after moving

func _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

4. Coyote time (forgiving jump just after leaving a ledge)

@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() ...

Pitfalls

  • 3.x signature is gone. move_and_slide(velocity) (returning the new velocity) was removed. In 4.x set the velocity property and call move_and_slide() with no args. move_and_slide(velocity, Vector2.UP) will not parse.
  • Multiplying velocity by delta. move_and_slide() already accounts for the physics delta. Setting velocity = dir * speed * delta makes the body crawl.
  • Movement in _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.
  • Sinking through floors usually means the collision shape is missing/zero-sized, the 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().
  • Slope slipping while idle: keep floor_stop_on_slope = true (default) and set a floor_snap_length so the body sticks to downward slopes.

References

  • For one-way platforms, moving platforms, jump buffering, variable jump height, and move_and_collide() (manual collision response), read references/controller-recipes.md.

Related skills

  • 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.

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Godot 4.x 中 2D 角色移动的完整解决方案,包含平台跳跃、俯视角移动、斜坡处理等实用模式
  • 面向游戏开发者解决具体开发痛点,实用价值高
Trigger Precision75/100

Areas to improve

  • description内容重复且未明确触发关键词 Reported severity: Minor

    frontmatter 和 skill_body 中 description 字段内容完全重复,且未提炼出明确的触发关键词

    Recommendation: 建议在 description 中提炼核心触发关键词,如 'Godot 2D 角色移动'、'平台跳跃'、'俯视角移动' 等,避免重复

Highlights

  • 'When to use' 部分清晰界定了适用场景和不适用场景,边界较为清晰
Structure and Standards95/100

Highlights

  • 文档结构完整,包含 When to use、Core workflow、Patterns、Pitfalls、References、Related skills 等章节
  • 提供了多个端到端的 GDScript 代码示例,步骤清晰,frontmatter 完整
Execution Reliability90/100

Highlights

  • 提供的 GDScript 代码示例语法正确,参数合理,覆盖了常见陷阱
  • 工具来源明确(Godot 官方 API),执行可靠性高
Evidence Verifiability (mean of the first four)86/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.