$npx -y skills add thedivergentai/GD-Agentic-Skills --skill godot-2d-animationExpert patterns for 2D animation in Godot using AnimatedSprite2D and skeletal cutout rigs. Use when implementing sprite frame animations, procedural animation (squash/stretch), cutout bone hierarchies, or frame-perfect timing systems. Trigger keywords: AnimatedSprite2D, SpriteFra
| 1 | ## Godot 4.7 Baseline |
| 2 | |
| 3 | - Expert patterns in this skill target **Godot 4.7+** (stable, 2026-06-18). |
| 4 | - Consult the [Godot 4.7 migration guide](https://docs.godotengine.org/en/4.7/tutorials/migrating/upgrading_to_godot_4.7.html) when upgrading projects from 4.6. |
| 5 | - **NEVER** assume 4.6 defaults (stretch mode, audio area_mask, RichTextLabel percent flags) without checking 4.7 migration notes. |
| 6 | |
| 7 | # 2D Animation |
| 8 | |
| 9 | Expert-level guidance for frame-based and skeletal 2D animation in Godot. |
| 10 | |
| 11 | ## NEVER Do |
| 12 | |
| 13 | - **NEVER use AnimatedTexture** — This class is deprecated, highly inefficient in modern renderers, and may be removed in future Godot versions. Use AnimatedSprite2D or AnimationPlayer instead. |
| 14 | - **NEVER allow Tweens to fight over the same property** — If multiple Tweens animate the same property, the last one created forcibly takes priority. Always assign your Tween to a variable and call `kill()` on the previous instance before creating a new one. |
| 15 | - **NEVER process kinematic movement outside the physics tick** — If your AnimationPlayer moves a CharacterBody2D, ensure the AnimationPlayer's callback mode is set to Physics. Animating physics bodies during the Idle (render) frame breaks fixed timestep physics interpolation and causes stutter. |
| 16 | - **NEVER use `animation_finished` for looping animations** — The signal only fires on non-looping animations. Use `animation_looped` instead for loop detection. |
| 17 | - **NEVER call `play()` and expect instant state changes** — AnimatedSprite2D applies `play()` on the next process frame. Call `advance(0)` immediately after `play()` if you need synchronous property updates (e.g., when changing animation + flip_h simultaneously). |
| 18 | - **NEVER set `frame` directly when preserving animation progress** — Setting `frame` resets `frame_progress` to 0.0. Use `set_frame_and_progress(frame, progress)` to maintain smooth transitions when swapping animations mid-frame. |
| 19 | - **NEVER forget to cache `@onready var anim_sprite`** — The node lookup getter is surprisingly slow in hot paths like `_physics_process()`. Always use `@onready`. |
| 20 | - **NEVER mix AnimationPlayer tracks with code-driven AnimatedSprite2D** — Choose one animation authority per sprite. Mixing causes flickering and state conflicts. |
| 21 | - **NEVER use paper-thin skeletons for deformation** — 2D meshes require balanced vertex density. If your mesh deforms poorly, increase the vertex count near joints in the Mesh2D editor. |
| 22 | |
| 23 | --- |
| 24 | |
| 25 | ## Available Scripts |
| 26 | |
| 27 | > **MANDATORY**: Read the appropriate script before implementing the corresponding pattern. |
| 28 | |
| 29 | ### [animation_sync.gd](scripts/animation_sync.gd) |
| 30 | Method track triggers for frame-perfect logic (SFX/VFX hitboxes), signal-driven async gameplay orchestration, and AnimationTree blend space management. Use when syncing gameplay events to animation frames. |
| 31 | |
| 32 | ### [animation_state_sync.gd](scripts/animation_state_sync.gd) |
| 33 | Frame-perfect state-driven animation with transition queueing - essential for responsive character animation. |
| 34 | |
| 35 | ### [shader_hook.gd](scripts/shader_hook.gd) |
| 36 | Animating ShaderMaterial uniforms via AnimationPlayer property tracks. Covers hit flash, dissolve effects, and instance uniforms for batched sprites. Use for visual feedback tied to animation states. |
| 37 | |
| 38 | ### [procedural_squash_stretch.gd](scripts/procedural_squash_stretch.gd) |
| 39 | Dynamic physics-driven deformation. Provides `lerp` logic for smoothing out sudden impact squashes and directional stretches based on high-velocity movement. |
| 40 | |
| 41 | ### [skeleton_2d_rig_helper.gd](scripts/skeleton_2d_rig_helper.gd) |
| 42 | Programmatic rig management. Tuning FABRIK/CCDIK modification stacks and updating bone rest poses at runtime for procedural limb goal-reaching. |
| 43 | |
| 44 | ### [animation_tree_step.gd](scripts/animation_tree_step.gd) |
| 45 | Expert state machine control. Utilizes `AnimationNodeStateMachinePlayback.travel()` to leverage the engine's internal A* pathfinding for multi-state transitions. |
| 46 | |
| 47 | ### [one_frame_sync_fix.gd](scripts/one_frame_sync_fix.gd) |
| 48 | Eliminates the "One-Frame Glitch" by using `advance(0)` to force the engine to apply animation poses immediately alongside property changes like `flip_h`. |
| 49 | |
| 50 | ### [gpu_mesh_optimizer.gd](scripts/gpu_mesh_optimizer.gd) |
| 51 | Architectural pattern for bypassing GPU fill-rate bottlenecks. Demonstrates when to convert large sprites into specialized 2D meshes to avoid transparent pixel overhead. |
| 52 | |
| 53 | ### [multimesh_swarm_anim.gd](scripts/multimesh_swarm_anim.gd) |
| 54 | Optimization for thousands of entities. Offloads animation logic (sine waves, fl |