> 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 的情绪数据默认在每个 `Convai 聊天机器人` 组件上启用——只有当你想要一种自定义实现，将这些分数映射到角色的 Skeletal Mesh 上的 morph target 时，才参考本指南。到最后，在编辑器中进入 Play In Editor 并与角色说话时，你会实时看到可见的表情变化。

### 你将构建什么

每当 `UConvaiChatbotComponent` 接收到来自 Convai 的新情绪状态时，使用 `获取情绪分数`读取每种情绪的分数，并使用 `设置形态目标`.

### 先决条件

开始前，请确认：

* 已安装 Convai Unreal Engine 插件，并已配置 API 密钥。
* 角色 Actor 已放置在你的关卡中，并且有一个可用的 `Convai 聊天机器人` 组件（你与它交谈时，角色已经会说话）。
* 角色的 Skeletal Mesh 拥有你想要驱动的情绪对应的 morph target——请查看 **Morph Targets** 选项卡，在 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 Name** 到 Skeletal Mesh **Morph Targets** 选项卡中的准确名称，并将分数连接到 **值**.
{% 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 Name** 在每个 `设置形态目标` 节点上的名称与角色 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 的设置通常使用不同的命名约定——请直接从 **Morph Targets** 选项卡复制名称，而不要假定固定列表。

### 下一步

{% 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" %}
[Emotion 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 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-unreal-engine-plugin/features/emotion/emotion-quick-start.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.
