> 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/core-concepts/dialogue-state.md).

# 对话状态

了解具身化模块读取的八值对话状态，以判断角色是空闲、聆听还是说话中。

每个体现模块——目光、身体动画、肢体语言和情绪——都读取同一个八值 `DialogueState` 来知道角色当前处于对话的哪个节拍。Conversation Flow 是唯一决定这个值的模块；其他所有模块都只读取它。理解每个状态的含义，会让其余体现模块的行为更易读懂。

***

### 这八个对话状态

`DialogueState` (`SDK/Domain/Embodiment/Semantics/DialogueState.cs`）是贯穿整个体现栈共享的标准对话阶段模型。

| 状态     | 值   | 它在对话中的含义                                                                      |
| ------ | --- | ----------------------------------------------------------------------------- |
| `Idle` | `0` | 角色当前并未参与某一轮对话。空闲的微行为——重心转移、环境目光——占主导。                                         |
| `聆听`   | `1` | 玩家正在说话，角色在积极倾听。目光会固定到玩家身上，肢体语言通常会向前倾，而情绪则保持接近中性。                              |
| `关注`   | `2` | 角色正在朝一个关注目标进行定向——例如玩家准备开启一轮发言——此时玩家还没有开始说话；或者它正在两次节拍之间维持一种参与对话的姿态，随后再冷却回环境空闲。 |
| `思考`   | `3` | 玩家已经说完，但角色尚未回复。它模拟自然的认知停顿：目光可以移开，微眼跳增多，眉毛上扬。                                  |
| `说话`   | `4` | 角色当前正在说话。LipSync 接管嘴部，情绪和手势强度会随语音能量变化。                                        |
| `反应`   | `5` | 在一次重大事件之后的一个短暂反应节拍——出乎意料的玩家输入、一次高强度情绪到来。允许某个模块播放一次性动作，而不会干扰主状态。               |
| `已中断`  | `6` | 角色在一轮发言中途被打断。表现为短暂冻结，并在转回之前快速稳定下来 `关注`.                                       |
| `平复`   | `7` | 轮后冷却：角色已经说完，目光变得柔和，情绪逐渐衰减回静息基调，然后再交接给 `关注`.                                   |

这个模型刻意比粗略的空闲/倾听/说话划分更丰富。每个状态都代表自然对话中的一个独立节拍，这正是让目光、肢体语言、情绪和身体动画能够产生可信行为，而无需彼此硬编码覆盖规则的原因。

***

### 谁拥有这个状态，谁读取它

`ConvaiConversationFlowController` (`SDK/Modules/ConversationFlow/Components/ConvaiConversationFlowController.cs`）是角色对话状态的唯一权威来源。其他所有体现模块都只读取它；没有任何模块会重新定义或推断自己的版本。

控制器在其自己的公共接口上暴露两个成员：

| 成员        | 类型                                | 说明                                                                                                                                               |
| --------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Current` | `DialogueStateReading`            | 角色当前的读取值：一个 `Primary` 状态、正在过渡到的 `BlendTo` 状态、一个 `BlendWeight` 在 `[0, 1]`, `TimeInState` （以秒为单位），以及一个归一化的 `EnergyLevel` 在 `[0, 1]` ，用于缩放手势和微行为强度。 |
| `Changed` | `事件 Action<DialogueStateReading>` | 在读取值发生变化时触发。                                                                                                                                     |

读取值始终描述的是两个状态之间的混合，而不是硬切换，因此模块可以交叉淡化其输出，而不是突然跳变。当没有过渡正在进行时， `Primary` 和 `BlendTo` 相等，并且 `BlendWeight` 是 `0`.

***

### 当控制器被自动添加时

一个 `ConvaiConversationFlowController` 并不总是必须手动添加。 `ConvaiBodyAnimationController` 只要某个角色有身体动画但没有作者显式配置的控制器，系统就会自动为它添加一个，并且 Convai 只会记录一次日志，说明角色名称以及原因。自动添加的控制器与手动添加的行为完全一致——如果随包提供的时序不适合你的角色，之后再进行配置即可。

其他模块不会主动要求它。目光、肢体语言和情绪会在有对话状态时读取它，没有时则回退到 `Idle` 如果没有，则回退到 `Idle`。因此，只有这些模块而没有身体动画的角色将永远不会离开 `ConvaiConversationFlowController` 你自己。

{% hint style="info" %}
这个读取值背后的契约， `IConversationFlowSource`，是 `内部` 随包提供的。请读取 `ConvaiConversationFlowController.Current` 并订阅 `Changed` ——不要自己实现这个接口。
{% endhint %}

***

### 下一步

{% content-ref url="/pages/491cfe5f38fba67eb46308256f5d4fa1ba67cda0" %}
[角色具身化](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/character-embodiment.md)
{% endcontent-ref %}

{% content-ref url="/pages/8eaf58d7e1fc1a2176b0c4b26425f595bc8e8851" %}
[资产所有权与写时复制](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/asset-ownership.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/core-concepts/dialogue-state.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.
