> 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-unreal-engine-plugin/features/emotion/emotion-quick-start.md).

# 情绪快速入门

将 Convai 角色的情绪分数连接到其 Skeletal Mesh 上的 morph target，使面部表情在对话期间自动更新。

我们将把 Convai 角色的情绪分数连接到其 Skeletal Mesh 上的 morph target，这样角色在对话时面部表情就会自动更新。Convai 的情绪数据默认在每个 `Convai 聊天机器人` 组件上启用——只有在你想要自定义实现，将这些分数映射到角色 Skeletal Mesh 上的 morph target 时，才按本指南操作。到最后，在 Editor 中进入 Play In Editor 并与角色对话，就会实时看到明显的表情变化。

### 你将构建的内容

一个 Blueprint 事件处理器，每当 `UConvaiChatbotComponent` 从 Convai 接收到新的情绪状态时，会使用以下方式读取各情绪的分数： `获取情绪分数`，并使用以下方式将每个分数应用到角色 Skeletal Mesh 上对应的 morph target： `设置变形目标`.

### 前置条件

开始之前，请确认：

* 已安装 Convai Unreal Engine 插件，并已配置 API 密钥。
* 你的关卡中有一个角色 Actor，并且其 `Convai 聊天机器人` 组件正常工作（你与它对话时，角色已经会开口说话）。
* 角色的 Skeletal Mesh 具有你想要驱动的情绪对应的 morph target——请检查 **形态目标** 选项卡中查看 Skeletal Mesh 资源编辑器，并记下准确的名称。

{% hint style="info" %}
如果角色尚未设置完成，请先完成 [添加你的第一个角色](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/add-your-first-convai-character.md) ，然后返回这里。
{% endhint %}

### 在 Blueprint 中绑定事件

{% stepper %}
{% step %}

#### 打开角色蓝图

在 **内容浏览器**，打开角色 Actor 的 Blueprint。切换到 **事件图**.
{% endstep %}

{% step %}

#### 添加 On Emotion State Changed 事件

在 Event Graph 中右键并搜索 `当情绪状态更改时`。选择列在你的 `Convai 聊天机器人` 组件下的事件。此时会出现一个带有两个输出引脚的事件节点： **聊天机器人组件** 和 **交互玩家组件**.
{% endstep %}

{% step %}

#### 读取情绪分数

从 **聊天机器人组件** 输出引脚拖出，并搜索 `获取情绪分数`。将 **情绪** 你想首先驱动的类别——例如 `开心` ，用于微笑的 morph target。返回值是一个 `float` ，范围在 `0.0`–`1.0`.

对每个 `EBasicEmotions` 你的网格支持的类别都重复调用，或者先从一种情绪开始，以在添加其余项之前验证整个流程。
{% endstep %}

{% step %}

#### 将分数应用到 morph targets

对于每个 `获取情绪分数` 返回值，添加一个 `设置变形目标` 节点。将 **目标** 连接到你角色的 **骨骼网格组件**，设置 **Morph Target 名称** 连接到 Skeletal Mesh 中的准确名称 **形态目标** 选项卡中的名称，并将分数连接到 **值**.
{% endstep %}

{% step %}

#### 编译并保存

点击 **编译** 然后 **保存** 在蓝图编辑器工具栏中。

事件现在已连接。每当角色从 Convai 接收到新的情绪状态时，处理器就会触发，并更新你映射的 morph targets。
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**预期结果：** Blueprint 图表显示 `当情绪状态更改时` → 一个或多个 `获取情绪分数` → `设置变形目标` 链路，且全部连接无误。Blueprint 可干净地编译通过。
{% endhint %}

### 运行角色

进入 Play In Editor 并开始对话。与角色交谈并观察它的面部——随着角色对不同的情感内容作出回应，表情应会发生变化。

如果没有出现表情变化，请使用此检查清单：

* 该 `Convai 聊天机器人` 组件具有有效的 **角色 ID** ，并且插件可以连接到 Convai。
* 该 `当情绪状态更改时` 事件触发——添加一个 `打印字符串` 节点到处理器中进行验证。如果它始终不触发，则说明会话未连接，或者 Convai 未发送情绪数据。
* `获取情绪分数` 返回一个大于 `0.0` 的值（当角色说话时）——添加 `Print Float` 到分数节点之后进行确认。
* 该 **Morph Target 名称** 在每个 `设置变形目标` 节点上匹配角色 Skeletal Mesh 中的名称完全一致（区分大小写）。

参见 [排查情绪问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/emotion/troubleshoot-emotion.md) 以获取详细指导。

#### 工作原理

当你与角色交谈时， `UConvaiChatbotComponent` 接收到了 Convai 的情绪信号，并将服务器标签映射到一个 `EBasicEmotions` 值，基于服务器刻度计算出一个浮点分数（`刻度 / 3` 加上 `EmotionOffset`），并触发了 `当情绪状态更改时`。你的处理器读取了这些分数并将其应用到 Skeletal Mesh。有关每个阶段的完整说明，请参阅 [情绪系统如何工作](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/emotion/how-the-emotion-system-works.md).

将每个 `EBasicEmotions` 类别映射到你绑定上已存在的 morph target 名称。MetaHuman 和 Reallusion 的设置通常使用不同的命名约定——请直接从 **形态目标** 选项卡复制名称，而不要假设存在固定列表。

### 下一步

{% content-ref url="/pages/c3081281b873e1a1b00439a147d3db6877743003" %}
[情绪系统的工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/emotion/how-the-emotion-system-works.md)
{% endcontent-ref %}

{% content-ref url="/pages/9ac48061a03a0400ae6e1769df358c2fb2a82536" %}
[情绪 Blueprint 参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/emotion/emotion-blueprint-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/83566839f3555aa1855858bb1bc0c20ed5a973cc" %}
[情绪示例](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/emotion/emotion-examples.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-unreal-engine-plugin/features/emotion/emotion-quick-start.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.
