> 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/embodiment/how-embodiment-works.md).

# 具身化如何运作

了解 Convai 如何在运行时构建每个角色的具身化基础设施，以及模块每帧运行的固定顺序。

角色所携带的所有具身模块在该角色上共享同一个运行时对象。Convai 每帧都会按固定顺序运行这些模块，因此两个模块不会以相互冲突的方式写入同一根骨骼或同一个 BlendShape。本页介绍运行时会发生什么：角色开始运行时层级视图中会出现哪些内容、模块按什么顺序执行，以及为什么对 Animator 和面部的写入不会发生冲突。有关这些机制背后的组合根模型，请参阅 [角色具身](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/core-concepts/character-embodiment.md).

***

### 角色开始运行时，层级视图中会出现什么

角色上第一个解析自身的具身模块会在该角色的根对象上静默创建一个 `EmbodimentContext` 。你无需自行添加它——它带有 `[AddComponentMenu("")]`，因此不会显示在“添加组件”菜单中；但创建后，它就是一个普通组件：在层级视图中选中它，即可检查它解析出的内容。

之后，首次有模块需要相应基础设施时，上下文会提供模块共享的基础设施：

| 组件                               | 功能说明                                                                        | 如何查看                                                                |
| -------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `StandardRigBinding`             | 解析哪些骨骼和 BlendShape 对应哪些语义角色——头部、脊柱、张嘴等——适用于 Humanoid、ARKit、CC3/CC4 及其他常见绑定。 | 它会显示在“添加组件”菜单的 **Convai > 具身 > 角色绑定**中，但首次有模块需要绑定数据时，Convai 会为你添加它。 |
| `AnimatorConductor`              | Animator 参数的唯一写入者；模块通过它提交带名称的参数写入，而不是直接调用 `Animator.SetFloat` 。             | 隐藏（`[AddComponentMenu("")]`）——Convai 会为你添加它。                        |
| `EmbodimentTickScheduler`        | 按下文所述的执行顺序运行所有已注册模块。                                                        | 隐藏（`[AddComponentMenu("")]`）——Convai 会为你添加它。                        |
| `FacialBlendshapeCompositorHost` | 面部 BlendShape 的唯一写入者；它会将每个模块的贡献合成为一组数值。                                     | 隐藏（`[AddComponentMenu("")]`）——Convai 会为你添加它。                        |

Convai 特意不在层级视图中隐藏这些组件，即使它们不会出现在“添加组件”菜单中也是如此：无法选中和检查的组件，在角色行为异常时也就无法调试。

***

### 每帧中模块的运行顺序

需要逐帧执行工作的模块会向上下文注册为 `IEmbodimentTickable` ，而不是依赖 Unity 自身的 `Update` 顺序。调度器会按以下固定顺序，让所有已注册的可逐帧执行对象依次经过三个阶段： `Cognition`，然后是 `Expression`，然后是 `Finalize`.

实际上，这意味着 Conversation Flow、Gaze 和 Emotion 会在 `Cognition`阶段采集输入并更新读数，此时还没有任何模块向绑定写入数据。等到 Gaze 或 Body Animation 的驱动器在 `Expression`阶段运行时，它读取的对话状态已经是本帧的最新状态，而不是落后一帧。 `Finalize` 最后运行，确保面部合成器和 Animator 控制器只在所有模块都有机会提供贡献后，才应用各自的写入。

在一个阶段内，模块通过 `TickOrder` 值声明自身的执行位置——数值越小，越先运行——而不依赖它在层级视图中的位置，也不受其启用时机影响。重新设置 `GameObject` 的父子关系，或以不同顺序添加模块，都不会改变哪个模块先写入共享骨骼。

***

### 为什么两个模块不会争抢同一个 BlendShape

两个模块在同一帧中写入同一个 Animator 参数或同一个面部混合形状时，就可能出现明显的画面异常，而不是编译错误。Convai 通过确保 Animator 和面部各自只有一个写入者来避免此问题——分别是上表中的 `AnimatorConductor` 和 `FacialBlendshapeCompositorHost` 。

模块不会直接写入 `Animator.SetFloat` 或混合形状值，而是将意图提交给 Animator 协调器或合成器。对于已由其他模块拥有的参数，协调器会拒绝第二个模块的注册。合成器则根据 `ConvaiFacialCompositionProfile`中的区域规则，处理同一面部区域上的重叠控制权——角色说话时，情绪模块和口型同步模块都会作用于嘴部——而不是让最后写入的模块悄然覆盖其他模块。

{% hint style="info" %}
跨模块约定（例如注视模块如何通知身体动画模块转身）属于包内部的 `internal` 接口，并非公开的扩展点；只有组件及其配置文件才是。
{% endhint %}

***

### 出现异常时该查看什么

打开 **Convai > Embodiment Editor** ，即可直接查看此运行时状态： **Setup** 选项卡会显示各模块解析出的内容；在播放模式下， **Live** 选项卡会显示角色当前的对话状态和情绪分数。

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

{% content-ref url="/pages/73e995564a424dd193e693891d64a815b3e79450" %}
[具身化快速入门](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/quick-start.md)
{% endcontent-ref %}

{% content-ref url="/pages/5027f813885b08acbe9044a4bb7b9166e9b01bc2" %}
[排查具身化问题](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/troubleshooting.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/embodiment/how-embodiment-works.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.
