> 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-blueprint-reference.md).

# Emotion Blueprint 参考

受支持的基于分数驱动的情绪 Blueprint 节点和属性位于 `UConvaiChatbotComponent` （显示为 `Convai 聊天机器人` 在“详细信息”面板和组件列表中）。这些枚举 `EBasicEmotions` 是位于 `EEmotionIntensity` 在整个 Blueprint 中凡是使用情绪值的地方都可用。

### 属性

#### LockEmotionState

| 字段  | 值                                    |
| --- | ------------------------------------ |
| 类型  | `bool`                               |
| 类别  | `Convai \| 情绪`                       |
| 访问  | `BlueprintReadWrite`, `EditAnywhere` |
| 已复制 | 是                                    |
| 默认值 | `false`                              |

当 `true`时，来自服务器的传入情绪更新会被丢弃。在服务器路径上， `情绪状态更改时` 不 **不是** 在锁定时触发。设为 `false` 以恢复接收服务器驱动的情绪更新和事件。

`强制设置情绪` 是位于 `重置情绪状态` 在锁定时仍会更新状态并触发该事件。

#### EmotionOffset

| 字段  | 值                                    |
| --- | ------------------------------------ |
| 类型  | `float`                              |
| 类别  | `Convai`                             |
| 访问  | `BlueprintReadWrite`, `EditAnywhere` |
| 默认值 | `0.0`                                |

当服务器驱动的更新到达时，会先将所有计算出的情绪分数按此数值偏移，然后再将分数钳制到 `0.0`–`1.0`。源代码注释说明了一个有用范围为 `-1.0` 到 `1.0`。正值会放大感知到的强度；负值会减弱它。是否 **不是** 适用于通过 `强制设置情绪`.

### 函数

#### 强制设置情绪

```cpp
void ForceSetEmotion(EBasicEmotions BasicEmotion, EEmotionIntensity Intensity, bool ResetOtherEmotions = false)
```

从 Blueprint 中覆盖当前情绪状态，而无需等待服务器更新。应用的分数等于所选等级的 `EEmotionIntensity` 乘数（参见 [EEmotionIntensity](#eemotionintensity) 表）。 `EmotionOffset` 不会应用。

| 参数                   | 类型                  | 说明                     |
| -------------------- | ------------------- | ---------------------- |
| `BasicEmotion`       | `EBasicEmotions`    | 要设置的情绪类别               |
| `强度`                 | `EEmotionIntensity` | 强度等级——决定应用的分数乘数        |
| `ResetOtherEmotions` | `bool`              | 当 `true`，会先将所有其他情绪分数归零 |

`强制设置情绪` 触发 `情绪状态更改时` ，并在更新状态后立即触发。

#### 获取情绪分数

```cpp
float GetEmotionScore(EBasicEmotions Emotion)
```

以 `float` 范围内的 `0.0`–`1.0`返回单个情绪类别的当前分数。 `0.0` 如果该情绪当前没有分数条目，则返回

在服务器路径上，分数计算为 `server scale / 3 + EmotionOffset`，并钳制到 `0.0`–`1.0`。在 `强制设置情绪` 路径上，分数改用 `EEmotionIntensity` 乘数。

| 参数   | 类型               | 说明       |
| ---- | ---------------- | -------- |
| `情绪` | `EBasicEmotions` | 要查询的情绪类别 |

#### 重置情绪状态

```cpp
void ResetEmotionState()
```

将中的所有情绪分数归零 `EmotionState`。使用此函数可将角色恢复为中性表情——例如在过场动画结束时或切换到新场景时。

`重置情绪状态` 触发 `情绪状态更改时` 在将状态归零后。

### 事件

#### 情绪状态更改时

| 字段   | 值                        |
| ---- | ------------------------ |
| 显示名称 | `情绪状态更改时`                |
| 类型   | `BlueprintAssignable` 委托 |
| 类别   | `Convai`                 |

当情绪状态由服务器更新时（当 `LockEmotionState` 为 `false`时）、由 `强制设置情绪`或由 `重置情绪状态`时，会在游戏线程上触发。请在角色的 Blueprint 中绑定此事件以响应表情变化。

不会 **不是** 在 `LockEmotionState` 为 `true`.

**签名：**

| 输出引脚      | 类型                         | 说明                                                                 |
| --------- | -------------------------- | ------------------------------------------------------------------ |
| `聊天机器人组件` | `UConvaiChatbotComponent*` | 其情绪状态已更改的聊天机器人组件                                                   |
| `交互玩家组件`  | `UConvaiPlayerComponent*`  | 始终 `null` 在当前插件中于每条路径（服务器驱动、 `强制设置情绪`，以及 `重置情绪状态`）。使用前请对该引脚进行空值检查。 |

### 枚举引用

#### EBasicEmotions

{% hint style="info" %}
`期待` 存在于 C++ 枚举中，但标记为 `隐藏` ，并且未在 Blueprint 中暴露。不要在 Blueprint 图表中依赖它。
{% endhint %}

| 枚举值  | Blueprint 显示名称 |
| ---- | -------------- |
| `喜悦` | `开心`           |
| `信任` | `平静`           |
| `恐惧` | `害怕`           |
| `惊讶` | `惊讶`           |
| `悲伤` | `难过`           |
| `厌恶` | `无聊`           |
| `愤怒` | `生气`           |

#### EEmotionIntensity

| 枚举值    | Blueprint 显示名称 | 分数乘数（`强制设置情绪` 仅） |
| ------ | -------------- | ---------------- |
| `较不强烈` | `较不强烈`         | `0.25`           |
| `基本`   | `基本`           | `0.60`           |
| `更强烈`  | `更强烈`          | `1.00`           |

这些乘数仅在调用 `强制设置情绪` 时适用。服务器驱动的分数使用 `server scale / 3 + EmotionOffset` 代替。

### 相关页面

{% 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/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-blueprint-reference.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.
