> 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/narrative-design/narrative-design-quick-start.md).

# 叙事设计快速入门

我们将对 Convai 角色调用一个命名叙事触发器，并确认故事图会推进。完成设置后，按下绑定的按键会调用 **调用叙事设计触发器**；当 Convai 推进图时， **收到叙事章节时触发** 会打印新的 `叙事段 ID` 到屏幕上。

### 我们将构建什么

一个角色蓝图，用于绑定 **收到叙事章节时触发** 在其 `UConvaiChatbotComponent`则复制后期处理设置，然后调用 **调用叙事设计触发器** 当玩家按下按键时。一个 **打印字符串** 节点，以及 **输出日志** 用于确认段落切换。

### 先决条件

* Convai Unreal Engine 插件已安装，并且 API 密钥已配置。参见 [安装 Convai 插件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/install-the-convai-plugin.md) 是位于 [配置您的 API 密钥](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/configure-your-api-key.md).
* 一个角色 `Actor` 蓝图，带有一个 `UConvaiChatbotComponent` (`Convai 聊天机器人`）以及 `CharacterID` 设置为有效 ID。参见 [添加您的第一个 Convai 角色](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/add-your-first-convai-character.md).
* 在 Convai 仪表板中为该角色 ID 配置至少一个段落和一个触发器。参见 [叙事设计 | Playground](/api-docs/zh/convai-playground/character-customization/narrative-design.md).

在打开 Unreal Engine 之前，请在仪表板中确认：

| 检查    | 要验证什么                                                    |
| ----- | -------------------------------------------------------- |
| 图存在   | 该角色至少有一个段落和一个出站触发器。                                      |
| 触发器名称 | 请准确复制触发器名称——区分大小写。                                       |
| 可到达边  | 该触发器是角色起始段落的一个出站边。                                       |
| 角色 ID | 该 `CharacterID` on `UConvaiChatbotComponent` 与仪表板中的角色匹配。 |

### 构建蓝图

{% stepper %}
{% step %}

#### 打开角色蓝图

打开包含你的 Actor 蓝图 `UConvaiChatbotComponent`中， **事件图表**，然后在 **组件** 面板中单击该组件以选中它。
{% endstep %}

{% step %}

#### 绑定 On Narrative Section Received

将 `UConvaiChatbotComponent` 引用从 **组件** 面板拖入事件图。然后从组件引脚拖出并搜索 **收到叙事章节时触发**。选择 **分配 On Narrative Section Received** 以创建一个已绑定的事件节点。

生成的事件节点提供两个输出引脚： `聊天机器人组件` (`UConvaiChatbotComponent` 引用）和 `叙事段 ID` (`FString`).
{% endstep %}

{% step %}

#### 打印段落 ID

连接一个 **打印字符串** 节点到该事件的执行引脚。将 `叙事段 ID` 输出引脚连接到 **打印字符串**的 `字符串输入` 每当 Convai 推进故事图时，这都会将新的段落 ID 打印到屏幕上。
{% endstep %}

{% step %}

#### 在按键按下时调用 Invoke Narrative Design Trigger

在事件图中添加一个 **键盘** 事件节点（例如 `F` 键）。拖出 `UConvaiChatbotComponent` 引用从 **组件** 面板并调用 **调用叙事设计触发器** 其中的

设置 `触发器名称` 到触发器名称，务必与其在 Convai 仪表板中显示的完全一致（例如 `start_inspection`）。将 **按下** 键盘事件的执行引脚连接到 **调用叙事设计触发器**.

{% hint style="info" %}
`bAutoInitializeSession` 默认为 `true` on `UConvaiChatbotComponent`，这样会话就会在 **开始游戏**。如果你在会话连接之前按下该键，触发器会排队在 `PendingTriggers` 中，并在连接建立后重新播放。
{% endhint %}
{% endstep %}

{% step %}

#### 在编辑器中运行并激活触发器

单击 **在编辑器中运行**。会话连接后，按下你绑定的按键。留意屏幕上是否打印出段落 ID 字符串。

如果触发器名称与角色当前段落可到达的触发器匹配，Convai 会推进故事图并 **收到叙事章节时触发** 触发并带有新的 `叙事段 ID`.

如果没有任何内容打印，请参见 [排查叙事设计问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/troubleshoot-narrative-design.md)。常见原因：触发器名称不匹配，错误的 `CharacterID`，或者仪表板中未将触发器连接到当前段落。
{% endstep %}
{% endstepper %}

屏幕上打印出一个非空段落 ID，表示 Convai 已接收到触发器并推进了故事图。

### 下一步

{% content-ref url="/pages/ff19704aac20f7d6e4bf5c3214636ccbe4248151" %}
[叙事触发器](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/narrative-triggers.md)
{% endcontent-ref %}

{% content-ref url="/pages/453cd3ea71434b9c4a8a7da307779eeb39996f99" %}
[模板键](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/template-keys.md)
{% endcontent-ref %}

{% content-ref url="/pages/7df13f2b93b6b95a4cdb5669073a1869b071babe" %}
[叙事设计如何工作](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/how-narrative-design-works.md)
{% endcontent-ref %}

如果触发器调用已运行但在编辑器中运行时没有打印出段落 ID，请使用故障排除页面。

{% content-ref url="/pages/609986e3902c22d2027f232e5ffaaa507011c8a0" %}
[排查叙事设计问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/narrative-design/troubleshoot-narrative-design.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/narrative-design/narrative-design-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.
