> 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 角色添加一个现成动作，并确认其在 Play 模式下运行。

打开 Actions Editor，并将四个现成的入门动作之一添加到 Convai 角色，无需编写脚本。完成后，角色便能响应自然语言请求（例如“看着椅子”），在场景中实际执行相应行为。

### 前提条件

* [ ] 一个 `ConvaiCharacter` 组件已添加到 NPC 的 `GameObject`上，用于连接对话并作出回应。
* [ ] 至少一个角色应能对其执行操作的场景对象。

### 四个入门动作

对于尚无动作的角色，Actions Editor 都会按以下顺序提供相同的四个入门动作：

| 入门项   | 添加                                 | 角色所需组件                                              | 功能                        |
| ----- | ---------------------------------- | --------------------------------------------------- | ------------------------- |
| 移动到目标 | `ConvaiWalkToActionExecutor`       | `ConvaiNavMeshLocomotion` 和已烘焙的 NavMesh             | 走到指定的物体、人物或地点附近并停下        |
| 跟随玩家  | `ConvaiFollowPlayerActionExecutor` | `ConvaiNavMeshLocomotion` 和已烘焙的 NavMesh             | 以舒适的距离跟随玩家，直到收到停止指令       |
| 看向目标  | `ConvaiLookAtActionExecutor`       | `ConvaiGazeController` （Gaze 模块）                    | 将角色的眼睛、头部和身体转向指定目标        |
| 播放手势  | `ConvaiPlayGestureActionExecutor`  | `ConvaiBodyAnimationController` （Body Animation 模块） | 播放角色 Animation Set 中指定的手势 |

本页使用 **Look At Target**：它不需要烘焙 NavMesh，而且效果——角色转头看向某个物体——在 Play 模式下十分明显。Walk To Target 和 Follow The Player 则需要先在场景中烘焙 NavMesh（**Window > AI > Navigation**），角色才能实际移动到目的地；场景中有 NavMesh 后，也可以改用其中一个动作。

### 添加 Look At Target 入门动作

{% stepper %}
{% step %}

#### 标记目标物体

选择角色应看向的物体（例如椅子）。点击 **添加组件**，搜索 **Convai Action Target** (`Convai/Actions/Convai Action Target`），将 **Kind** 设为 `Object`，并为其指定一个清晰的 **名称**，例如 `chair`.
{% endstep %}

{% step %}

#### 打开 Actions Editor

选择 **Convai > Actions Editor**。窗口打开时会自动选中场景中唯一的 `ConvaiCharacter` ；如果场景中有多个角色，可在工具栏的 **角色** 字段中选择其他角色。
{% endstep %}

{% step %}

#### 在角色上启用动作

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

{% step %}

#### 添加 Look At Target 入门动作

如果还没有任何操作，窗口会显示四张入门卡片： **走向目标**, **跟随玩家**, **看向目标**和 **播放手势**。选择 **看向目标**.

Convai 会根据入门卡片预填一个 `Look At` 操作，将 `ConvaiLookAtActionExecutor` 添加到角色上；由于角色还没有 `ConvaiGazeController` ，也会在同一个可撤销步骤中将其添加。
{% endstep %}

{% step %}

#### 添加 Convai Action Runner

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

### 验证设置

切换回 **操作** 模式，并在左侧窗格中选择 `Look At` 操作。其 **试用** 框让你无需开始对话即可运行该操作：

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

{% hint style="success" %}
**预期结果：** 进入 Play 模式并说“看着椅子。”角色的眼睛、头部和身体会转向椅子，视线稳定后，操作便会报告成功。
{% endhint %}

如果角色没有转向，请打开 [角色操作故障排除](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/character-actions/debugging-and-troubleshooting.md) 查看诊断清单，或者选择 **Convai > 故障排除工具** 对整个角色进行一键式清单诊断。

### 后续步骤

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

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

{% content-ref url="/pages/c5598abd0ddd72fa75a0989ad602a5b4d12e16d7" %}
[编写自定义动作执行器](https://docs.convai.com/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
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=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
