$npx -y skills add thedivergentai/GD-Agentic-Skills --skill godot-animation-tree-masteryExpert patterns for AnimationTree including StateMachine transitions, BlendSpace2D for directional movement, BlendTree for layered animations, root motion, transition conditions, advance expressions, and state machine sub-states. Use for complex character animation systems with m
| 1 | # AnimationTree Mastery |
| 2 | |
| 3 | Expert guidance for Godot's advanced animation blending and state machines. |
| 4 | |
| 5 | ## NEVER Do |
| 6 | |
| 7 | - **NEVER call `play()` on AnimationPlayer when using AnimationTree** — AnimationTree controls the player. Directly calling `play()` causes conflicts and jitter. Use `set("parameters/transition_request")` or `travel()` instead [12]. |
| 8 | - **NEVER forget to set `active = true`** — AnimationTree is inactive by default. Animations won't play until `$AnimationTree.active = true` [13]. |
| 9 | - **NEVER use absolute paths for parameter access** — Use relative paths like `"parameters/StateMachine/transition_request"`. This ensures compatibility when nodes move in the hierarchy [14]. |
| 10 | - **NEVER leave `auto_advance` enabled for interactive states** — It causes immediate transitions. Use it only for automated sequences like combo chains or death-to-respawn [15, 121]. |
| 11 | - **NEVER use `BlendSpace2D` for 1D blending** — Blending only speed? Use `BlendSpace1D`. Blending only two states? Use `Blend2`. `BlendSpace2D` is specifically for X+Y directional inputs (strafe) [16, 142]. |
| 12 | - **NEVER update `AnimationTree` parameters every frame without a guard** — Setting parameters via `set()` every frame regardless of change causes cache invalidation and potential stutter. Check equality first. |
| 13 | - **NEVER use deep, nested `BlendTrees` for simple logic** — Every layer adds CPU overhead. If logic can be handled in a `StateMachine` or a simple script-driven `Blend2`, do it there. |
| 14 | - **NEVER forget to handle `await get_tree().process_frame` when updating parameters synchronously** — Sometimes the tree needs one frame to reconcile state before the next parameter change takes effect. |
| 15 | - **NEVER rely on `auto_advance` for long cutscenes** — If an animation is interrupted, `auto_advance` can put the character in a broken state. Use `Method Tracks` to signal state completion instead. |
| 16 | - **NEVER use `Sync` groups for animations with wildly different lengths** — It forces one animation to play at an extreme speed. Use `TimeScale` or separate layers for mismatching cycles. |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Godot 4.7: AnimationTree |
| 21 | |
| 22 | - `LookAtModifier3D.relative` default is now **false** (was true). |
| 23 | - Blend space `add_blend_point` accepts optional **name** parameter for labeled points. |
| 24 | |
| 25 | ## Available Scripts |
| 26 | |
| 27 | > **MANDATORY**: Read the appropriate script before implementing the corresponding pattern. |
| 28 | |
| 29 | ### [sync_parameter_manager.gd](scripts/sync_parameter_manager.gd) |
| 30 | Expert management of `AnimationTree` parameters with guards to prevent redundant updates and GPU cache churn. |
| 31 | |
| 32 | ### [reactive_oneshot_vfx.gd](scripts/reactive_oneshot_vfx.gd) |
| 33 | Using `AnimationNodeOneShot` for high-priority reactive animations like recoil, blinks, and hit reactions. |
| 34 | |
| 35 | ### [dynamic_timescale_control.gd](scripts/dynamic_timescale_control.gd) |
| 36 | Runtime manipulation of playback speed for bullet-time effects or movement haste multipliers. |
| 37 | |
| 38 | ### [advanced_transition_masking.gd](scripts/advanced_transition_masking.gd) |
| 39 | Procedural bone filtering (masking) for nodes like `Add2` to separate upper/lower body animations. |
| 40 | |
| 41 | ### [statemachine_travel_code.gd](scripts/statemachine_travel_code.gd) |
| 42 | Programmatic control of `AnimationNodeStateMachinePlayback` using `travel()` and `start()`. |
| 43 | |
| 44 | ### [blendtree_logic_mixing.gd](scripts/blendtree_logic_mixing.gd) |
| 45 | Complex mixing patterns for `BlendTree` nodes to create interactive combat layers. |
| 46 | |
| 47 | ### [root_motion_animtree_sync.gd](scripts/root_motion_animtree_sync.gd) |
| 48 | Expert 3D CharacterBody motion extraction optimized specifically for `AnimationTree` nodes. |
| 49 | |
| 50 | ### [sync_group_layering.gd](scripts/sync_group_layering.gd) |
| 51 | Using Sync Groups to keep multi-layered animations (e.g. walk and reload) perfectly aligned. |
| 52 | |
| 53 | ### [nested_tree_architecture.gd](scripts/nested_tree_architecture.gd) |
| 54 | Pattern for managing hierarchical State Machines and nested node parameter paths. |
| 55 | |
| 56 | ### [runtime_tree_debugging.gd](scripts/runtime_tree_debugging.gd) |
| 57 | Interactive tool for visualizing current states, transition paths, and blend values in real-time. |
| 58 | |
| 59 | --- |
| 60 | |
| 61 | ## Core Concepts |
| 62 | |
| 63 | ### AnimationTree Structure |
| 64 | |
| 65 | ``` |
| 66 | AnimationTree (node) |
| 67 | ├─ Root (assigned in editor) |
| 68 | │ ├─ StateMachine (common) |
| 69 | │ ├─ BlendTree (layering) |
| 70 | │ └─ BlendSpace (directional) |
| 71 | └─ anim_player: NodePath → points to AnimationPlayer |
| 72 | ``` |
| 73 | |
| 74 | ### Parameter Access |
| 75 | |
| 76 | ```gdscript |
| 77 | # Set parameters using string paths |
| 78 | $AnimationTree.set("parameters/StateMachine/transition_re |