> 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/emotion/how-the-emotion-system-works.md).

# 情绪系统的工作原理

Convai 情绪系统通过四阶段流程将服务器端的情绪信号转换为实时面部动画。本页将说明每个阶段如何工作、所需组件的作用，以及它们在场景中的放置位置。

### 情绪管线的工作方式

每个情绪信号都会经过四个阶段：

```mermaid
flowchart TD
    A([Convai 后端]) -->|RTVI bot-emotion 消息\n情绪标签 + 1–3 级别| B[RTVIBotEmotionMessage]
    B --> C[CharacterEmotionChanged\n领域事件]
    C --> D[ConvaiEmotionController]
    D --> E{分类法\n解析}
    E -->|别名 → 规范标签| F[EmotionScoreAccumulator\n平滑 · 微爆发]
    F --> G[NeutralAlternator\n周期性淡出为中性]
    G --> H{输出绑定}
    H --> I[BlendshapeEmotionBinding\n面部 Blendshape]
    H --> J[AnimatorParameterEmotionBinding\nAnimator 浮点参数]
    I & J --> K([EmotionReading\n由你的脚本读取])
```

后端发送一个简短的情绪标签（例如 `“happy”`）以及 1–3 级别的强度。 **分类法** 将该标签解析为其规范形式（`“joy”`），将强度标准化为 0–1 分数，并将其交给 **分数累加器**，它会应用指数平滑和可选的微表情爆发。 **中性轮换器** 会定期将表情逐渐回退到中性，以防止在长时间对话中面部冻结在单一姿态。随后，平滑后的分数会通过可配置的 **输出绑定**.

### 核心概念

| 概念                          | 是什么                                                                                                         |
| --------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `ConvaiEmotionController`   | 负责单个 NPC 整个管线的 MonoBehaviour。每个角色添加一个。                                                                      |
| `ConvaiEmotionProfile`      | 一个 ScriptableObject 资源，保存所有可调参数：平滑、微爆发、中性轮换以及输出槽定义。                                                         |
| `EmotionTaxonomyAsset`      | 一个 ScriptableObject，用于定义情绪词汇表——规范标签、服务器别名以及口部影响提示。内置默认集为 Plutchik 的九种情绪，包括中性。                               |
| 输出绑定                        | `BlendshapeEmotionBinding` 和 `AnimatorParameterEmotionBinding` 将每个规范情绪标签映射到网格 Blendshape 名称或 Animator 浮点参数。 |
| `EmotionReading`            | 当前情绪状态的不可变快照：主导标签、主导分数、所有分数，以及供 LipSync 使用的口部影响提示。可通过以下方式在每帧访问： `ConvaiEmotionController.Current`.          |
| 微爆发                         | 当新情绪到达时应用的短暂超调，让表情在稳定到持续水平之前先有一个更有力的入场。                                                                     |
| 中性轮换                        | 一个定时器，会周期性地将当前表情淡出到中性再返回，从而防止角色在长时间对话中脸部锁定在单一姿势。                                                            |
| `ConvaiCharacterEventRelay` | 一个对 Inspector 友好的组件，可将情绪变化回调作为 Unity Events 暴露出来——无需代码。                                                     |

### 组件放置

| 组件                          | 放置位置                                      | 说明                                                    |
| --------------------------- | ----------------------------------------- | ----------------------------------------------------- |
| `ConvaiEmotionController`   | 在 NPC 的根 GameObject 上，和 Embodiment 组件放在一起 | 每个角色一个                                                |
| `ConvaiEmotionProfile`      | 位于你的 `Assets/` 文件夹中的 ScriptableObject 资源  | 如有需要，可在多个 NPC 预制体之间共享                                 |
| `EmotionTaxonomyAsset`      | 位于你的 `Assets/` 文件夹                        | 可选——省略则使用内置的 Plutchik 集合                              |
| `ConvaiCharacterEventRelay` | 场景中的任意 GameObject 上                       | 自动解析 `ConvaiCharacter` 在同一个 GameObject 上；如有需要，可拖入不同角色 |

### 下一步

{% content-ref url="/pages/e4e5139a33824d66acc5af79e26ea948910fdcd0" %}
[情绪快速开始](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/emotion/quick-start.md)
{% endcontent-ref %}

{% content-ref url="/pages/5a9247365092d958f2d539ae98bdfe69f72df091" %}
[情绪配置文件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/emotion/emotion-profile.md)
{% endcontent-ref %}

{% content-ref url="/pages/39d161d99d04e6ca98725c740d134ccb5eac9e73" %}
[情绪脚本 API](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/emotion/scripting-api.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/features/emotion/how-the-emotion-system-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.
