> 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`) 是整个具身栈共享的标准对话阶段模型。

| State         | 值   | 在对话中的含义                                                                      |
| ------------- | --- | ---------------------------------------------------------------------------- |
| `空闲`          | `0` | 角色没有参与任何轮次。静止微行为——重心移动、环境凝视——占主导。                                            |
| `倾听`          | `1` | 玩家正在说话，角色在积极倾听。视线会锁定玩家，肢体语言往往会前倾，情绪则保持接近中性。                                  |
| `关注中`         | `2` | 角色正在朝一个焦点目标定向——例如玩家准备开启一个回合——但玩家尚未开始说话；或者它在两个节拍之间保持一种处于对话参与状态的姿态，然后再冷却回环境静止。 |
| `思考`          | `3` | 玩家已经说完，而角色尚未回应。模拟自然的认知停顿：视线可以移开，微扫视增多，眉毛抬起。                                  |
| `说话`          | `4` | 角色当前正在说话。LipSync 接管嘴部，而情绪和手势强度会随着语音能量变化。                                     |
| `反应`          | `5` | 在重大事件之后的一小段反应节拍——例如意料之外的玩家输入、高强度情绪到达。允许某个模块播放一次性动作而不打扰主状态。                   |
| `Interrupted` | `6` | 角色在回合中途被打断。表现为短暂僵住并迅速稳定，然后再过渡回 `关注中`.                                        |
| `平复`          | `7` | 回合后的冷却：角色已经说完，视线变得柔和，情绪逐渐衰减回其静息基调，然后再交接给 `关注中`.                              |

该模型被刻意设计得比粗略的静止/倾听/说话划分更丰富。每个状态都代表自然对话中的一个不同节拍，这正是它让 Gaze、Body Language、Emotion 和 Body Animation 能够产生可信行为，而无需彼此硬编码覆盖的原因。

***

### 谁拥有该状态，谁读取它

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

该控制器在其公开接口上暴露两个成员：

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

一个读数始终描述的是两个状态之间的混合，而不是硬切换，因此模块可以让输出交叉淡入淡出，而不是突然跳变。当没有进行中的过渡时， `主` 和 `BlendTo` 两者相等，并且 `BlendWeight` 为 `0`.

***

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

某个 `ConvaiConversationFlowController` 不一定非要手动添加。 `ConvaiBodyAnimationController` 会请求一个，所以一个带有身体动画但没有手工编写控制器的角色会自动获得一个，Convai 也会记录一次日志，说明角色名称以及原因。自动添加的控制器的行为与您自己添加的完全一样——如果随附的时序不适合您的角色，之后再进行配置。

其他模块不会请求一个。Gaze、Body Language 和 Emotion 会在对话状态存在时读取它，否则回退到 `空闲` 如果不存在则如此。因此，一个只有这些模块而没有身体动画的角色将永远不会离开 `空闲`，其行为会保持平淡，对对话没有响应。如果您看到的是这种情况，请添加一个 `ConvaiConversationFlowController` 自己添加。

{% hint style="info" %}
支撑这一读数的契约， `IConversationFlowSource`，是 `internal` 属于该包。请阅读 `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 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/core-concepts/dialogue-state.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.
