> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/quick-start.md).

# 角色动作快速入门

打开 Actions Editor，并将其中四个现成的起始动作之一添加到一个 Convai 角色上，无需编写脚本。完成后，角色会对自然语言请求——例如“看椅子”——做出响应，并在你的场景中实际执行该行为。

### 前提条件

* [ ] 某个 `ConvaiCharacter` 你 NPC 身上已经存在的组件 `GameObject`，用于连接并回应对话。
* [ ] 至少一个场景对象，角色应当能够对其执行操作。

### 这四个起始动作

Actions Editor 会为每个尚未拥有动作的角色提供相同的四个起始项，按以下顺序排列：

| 入门                                       | 新增                                 | 角色所需条件                                   | 作用                   |
| ---------------------------------------- | ---------------------------------- | ---------------------------------------- | -------------------- |
| 走向目标                                     | `ConvaiWalkToActionExecutor`       | `ConvaiNavMeshLocomotion` 以及已烘焙的 NavMesh | 走向指定的对象、人物或地点，并在附近停下 |
| 跟随玩家                                     | `ConvaiFollowPlayerActionExecutor` | `ConvaiNavMeshLocomotion` 以及已烘焙的 NavMesh | 以舒适的距离跟随玩家，直到被告知停止   |
| 注视目标                                     | `ConvaiLookAtActionExecutor`       | `ConvaiGazeController` （凝视模块）            | 将角色的眼睛、头部和身体转向指定目标   |
| 而改为使用——这两个行为驱动同一个 Animator，如果一起使用就会互相冲突。 | `ConvaiPlayGestureActionExecutor`  | `ConvaiBodyAnimationController` （身体动画模块） | 播放角色动画集中的指定手势        |

本页使用 **注视目标**：它不需要烘焙 NavMesh，而且效果——角色转头看向某物——在 Play 模式下会立刻显现。Walk To Target 和 Follow The Player 需要在场景中烘焙 NavMesh（**窗口 > AI > 导航**）之后角色才能真正到达任何地方；等你的场景中有了 NavMesh 后，再改用其中一个。

### 添加 Look At Target 起始项

{% stepper %}
{% step %}

#### 标记一个目标对象

选择角色应该看向的对象——例如一把椅子。点击 **Add Component**，搜索 **Convai Action Target** (`Convai/Actions/Convai Action Target`），保留 **类型** 处于同一 `对象`，并为它指定一个明确的 **Name**，例如 `椅子`.
{% endstep %}

{% step %}

#### 打开 Actions Editor

选择 **Convai > 动作编辑器**。窗口会打开，并自动选中场景中唯一的 `ConvaiCharacter` 会自动选中——如果你的场景中有多个，请从 **Character** 工具栏中的该字段中选择不同的一个。
{% endstep %}

{% step %}

#### 为角色启用动作

如果这是角色的第一个动作，窗口会显示一个一步式提示：点击 **启用动作**。这会添加 `ConvaiActionConfigSource` （标记为 **Convai Actions** （在 Inspector 中）将其添加到角色上——只需点击一次，且完全可撤销。
{% endstep %}

{% step %}

#### 添加 Look At Target 起始项

在尚未添加任何动作时，窗口会显示四张起始卡片： **走向目标**, **跟随玩家**, **注视目标**，以及 **而改为使用——这两个行为驱动同一个 Animator，如果一起使用就会互相冲突。**。选择 **注视目标**.

Convai 会创建一个 `注视` 预先填充起始项内容的动作，并添加 `ConvaiLookAtActionExecutor` 到角色上，并且——由于该角色还没有 `ConvaiGazeController` ——也会在同一个可撤销步骤中将其添加进去。
{% endstep %}

{% step %}

#### 添加 Convai Action Runner

将角色选择器下方的模式选择器从 **动作** 到 **角色设置**。如果列表中没有 dispatcher，请点击 **添加 Action Runner** 来添加 `ConvaiActionDispatcher` （标记为 **Convai 动作运行器** （在 Inspector 中）添加到角色上。
{% endstep %}
{% endstepper %}

### 验证设置

切换回 **动作** 模式，并选择 `注视` 左侧窗格中的动作。其 **试试** 框可让你在不开始对话的情况下运行该动作：

* **在编辑模式下**，这是一个 **预览**：输入 `椅子` 到 dry-run 字段中，并确认它会解析到你标记的目标。
* **在播放模式下**，这是一个 **测试运行**：选择 `椅子` 来自 **有效目标** 并点击 **立即运行**。角色应该会立即转向椅子，无需对话，也不会涉及后端调用。

{% hint style="success" %}
**预期结果：** 进入 Play 模式并说“看椅子”。角色的眼睛、头部和身体会转向它，并且一旦凝视稳定下来，动作就会报告成功。
{% endhint %}

如果角色没有转身，请打开 [排查角色动作问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/debugging-and-troubleshooting.md) 查看诊断检查清单，或者选择 **Convai > 故障排查工具** 进行一键式、检查清单风格的整个角色诊断。

### 下一步

{% content-ref url="/pages/b1d09b6e9430d66a69feaa877bc4844f6ed840d0" %}
[动作编辑器](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/actions-editor.md)
{% endcontent-ref %}

{% content-ref url="/pages/f592d9dc3ad261e175159690b86cdd4b50bb4d81" %}
[动作执行器](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/action-executors.md)
{% endcontent-ref %}

{% content-ref url="/pages/c5598abd0ddd72fa75a0989ad602a5b4d12e16d7" %}
[编写自定义动作执行器](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/writing-custom-executors.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/quick-start.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
