# animtree

> 查询、控制和编辑 AnimationTree。支持创建节点、添加状态、添加转换、设置混合参数、播放状态、编辑状态属性。运行时操作，仅影响当前执行上下文。如需持久化，请编辑 .tscn 文件。

| 属性 | 值 |
|------|-----|
| 所属层 | headless |
| 安全级别 | guarded |
| 需要 Godot | 是 |
| 需要编辑器 | 否 |
| 只读 | 否 |
| 长耗时 | 否 |

## Actions

- `animtree_create`
- `animtree_add_state`
- `animtree_add_transition`
- `animtree_set_blend`
- `animtree_play`
- `animtree_state_edit`

## Parameters

| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| `action` | enum (6 项) | ✓ | 操作类型：animtree_create 创建 AnimationTree 节点；animtree_add_state 添加状态；animtree_add_transition 添加转换；animtree_set_blend 设置混合参数；animtree_play 播放状态；animtree_state_edit 编辑状态属性 |
| `project_path` | string |  | Godot 项目目录路径（可选，默认使用 GODOT_PROJECT_PATH 环境变量或当前目录） |
| `node_path` | string |  | AnimationTree 节点路径 |
| `name` | string |  | AnimationTree 节点名称（animtree_create 时使用） |
| `parent` | string |  | 父节点路径（animtree_create 时使用，默认 root） |
| `animation_player_path` | string |  | AnimationPlayer 的 NodePath（animtree_create 时使用） |
| `tree_root_type` | enum: AnimationNodeStateMachine | AnimationNodeBlendTree | AnimationNodeBlendSpace2D |  | 根节点类型（animtree_create 时使用，默认 AnimationNodeStateMachine） |
| `state_name` | string |  | 状态名称 |
| `animation` | string |  | 关联的 Animation 名称（animtree_add_state 时使用） |
| `position` | object |  | 位置 {x, y} |
| `from_state` | string |  | 源状态名称（animtree_add_transition 时使用） |
| `to_state` | string |  | 目标状态名称（animtree_add_transition 时使用） |
| `xfade_time` | number |  | 交叉淡入淡出时间（秒，animtree_add_transition 时使用） |
| `conditions` | array |  | 转换条件列表（animtree_add_transition 时使用） |
| `parameter_name` | string |  | 参数名称 |
| `value` | any |  | 参数值（float 用于 blends，{x,y} 用于 blend spaces） |
| `sub_action` | enum: set_position | set_blend |  | animtree_state_edit 的子操作：set_position 设置状态位置(需 state_name + position)；set_blend 设置混合参数(需 parameter_name + value) |
| `load_autoloads` | boolean |  | 是否加载 Autoload 上下文（默认 true） |

## 风险分布

读 1 / 写 5

---
<!-- AUTO-GENERATED by scripts/gen-tool-docs.mjs from capability-matrix.json v0.32.21. DO NOT edit manually; re-run npm run gen:tool-docs after tool changes. -->
