> 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/utilities/dialogue-animation/how-dialogue-animation-works.md).

# 对话动画如何工作

对话动画模块以对话状态和检测到的情绪作为输入，驱动 AI 角色的身体和头部手势动画。它不再为每个动画片段硬编码动画器状态，而是使用一个 `AnimatorOverrideController` 在运行时从一个池化库中注入动画片段——随着对话推进动态切换候选片段。该模块完全在 Unity 内运行。没有任何动画数据会发送到 Convai。

***

### 对话状态与层控制

每一帧，模块都会读取两个信号：当前的 **对话状态** （待机、倾听、思考、说话、 प्रतिक्रिया）以及当前的 **情绪读数** ，来自 Emotion 模块。它使用这些信号从一个 `DialogueAnimationLibrary` 中选择并交叉淡入淡出动画片段，并在四层动画器栈中进行播放。

```mermaid
graph LR
    A[对话状态] --> C[ConvaiDialogueAnimationController]
    B[情绪读数] --> C
    C --> D[层 0：基础待机]
    C --> E[层 1：待机叠加]
    C --> F[层 2：身体对话]
    C --> G[层 3：头部对话]
```

这四层是可叠加且带遮罩的：基础待机会持续播放，待机叠加会增加变化，而当角色开口说话时，两个对话层会淡入。对话层动画片段通过 `DialogueTalkBodyCoverage` 进行路由——动画片段可以仅作用于头部、仅作用于身体，或同时作用于两者。

***

### 配置资源

该模块由四种 ScriptableObject 类型驱动：

| 资源                               | 用途                                 |
| -------------------------------- | ---------------------------------- |
| `DialogueAnimationLibrary`       | 待机和对话动画片段池，每个片段都标记了情绪亲和性和角色性别      |
| `DialogueAnimationRuntimeConfig` | 时序、混合时长、层权重以及选择参数                  |
| `DialogueAnimatorContract`       | 将层索引和状态名称映射到你的 Animator Controller |
| `ConvaiDialogueAnimationProfile` | 将上面的三个资源打包成单个角色预设                  |

SDK 附带三个打包配置文件： **均衡**, **富表现力**，和 **含蓄**。它们无需自定义制作即可覆盖大多数角色。

***

### 下一步

按照快速开始，在你的第一个角色上运行该模块，然后阅读动画库与配置文件，以了解动画片段池、时序以及完整字段参考。

{% content-ref url="/pages/cf0343f3a0b58d2e8e0e7f1a0c9eee9a6c5ecd1d" %}
[对话动画快速开始](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/utilities/dialogue-animation/quick-start.md)
{% endcontent-ref %}

{% content-ref url="/pages/0f3cbc0e4633317c448740563d0c38854e7725ee" %}
[动画库与配置文件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/utilities/dialogue-animation/animation-libraries-and-profiles.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:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/utilities/dialogue-animation/how-dialogue-animation-works.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
