Godot characterbody 2d

From thedivergentai/GD-Agentic-Skills · View interactive version

Godot characterbody 2d is an AI agent skill from the GitHub repository thedivergentai/GD-Agentic-Skills. Expert patterns for CharacterBody2D including platformer movement (coyote time, jump buffering, variable jump height), top-down movement (8-way, tank controls), collision handling, one-way platforms, and state machines. Use for player characters, NPCs, or enemies. Trigger keywords: CharacterBody2D,

How to use this skill

Skill file

CharacterBody2D Implementation

Expert CharacterBody2D feel systems — not beginner move_and_slide tutorials.

NEVER Do


When to Use CharacterBody2D

| Need | Body |

|------|------|

| Feel-driven player / NPC / enemy locomotion | CharacterBody2D |

| Rolling debris, ragdoll-ish props, force piles | RigidBody2D |

| Static level colliders | StaticBody2D / TileMapLayer physics |

Decision Tree → MANDATORY Scripts

| Task | Do First | Then (optional) | Do NOT Load |

|------|----------|-----------------|-------------|

| Platformer foundation (coyote, buffer, accel/friction) | expert_physics_2d.gd | — | Inline tutorial controllers |

| Isolate coyote/buffer only | frame_perfect_coyote_time.gd | — | Duplicate coyote blocks in SKILL |

| Variable jump / short hop | variable_jump_height.gd | — | — |

| Slopes / stairs | slope_stair_snapping.gd | godot-raycasting-queries | — |

| Wall slide / wall jump | wall_slide_jump_refined.gd or wall_jump_controller.gd | — | Both unless comparing |

| Dash + i-frames | dash_state_controller.gd or dash_controller.gd | — | Both unless comparing |

| Air control polish | aerial_drift_acceleration.gd | — | — |

| Ceiling stick / bonk | ceiling_bonk_detection.gd | — | — |

| Knockback / wind impulses | impulse_response_handler.gd | — | — |

| Pixel-art visuals | subpixel_movement_rounding.gd | — | Rounding global_position in physics |

| Many AI bodies | performance_character_pooling.gd | — | — |

| One-way platforms | Tile/StaticBody one-way + layers/masks | godot-tilemap-mastery / godot-2d-physics | position.y += 1 drop-through hacks |

| Top-down / tank locomotion | movement-recipes.md | — | Inline 8-way tutorials |

| Jump arc debug tuning | game_feel_profiler.gd | — | — |

| Animation root motion | root_motion_controller.gd | godot-2d-animation | — |

Golden path: Read expert_physics_2d.gd first. Add dash/wall/jump scripts only after that controller is in place. Do not re-inline coyote/buffer/accel loops in the scene when the script already owns them.

One-Way Platforms (correct recipe)

  1. Author one-way on the platform collider (CollisionShape2D one-way / TileSet physics one-way), not by teleporting the player.
  2. Put platforms and player on explicit collision layers/masks so drop-through can temporarily clear the platform bit (or disable collide-with) while holding down + jump — then restore next physics frames.
  3. Keep drop-through on the physics tick; never bypass move_and_slide with position nudges.
  4. For tile one-ways, align TileSet physics layers with CharacterBody masks — see godot-tilemap-mastery + godot-2d-physics.

Expert Character Architectures

1. Wall Cling (Variable Friction)

Monitor is_on_wall() while falling; scale velocity.y by a friction factor (optionally from tile custom data) instead of a binary wall-slide bool. Prefer wall_slide_jump_refined.gd over a bespoke cling fork.

2. Animation-Driven Movement (Root Motion)

Pull AnimationTree.get_root_motion_position(), convert to 2D, assign velocity = motion / delta, then move_and_slide(). Keeps feet locked to authored clips; pair with godot-2d-animation.

3. Game-Feel Profiler (Jump Arcs)

Debug-draw historical positions + current velocity in _draw() to visualize apex, coyote, and buffer windows while tuning exports on expert_physics_2d.gd — game_feel_profiler.gd.

MANDATORY for top-down/tank recipes, moving platforms, slide-collision response, and gotcha tables: movement-recipes.md. Do NOT Load when expert_physics_2d.gd already covers your platformer scope.

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API;

load Related Skills when routing work to a peer domain — do not preload the whole lattice.

Official Documentation

Related Skills

Prerequisites
Complements
Downstream / consumers
Master
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.