> 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).

# 叙事设计快速开始

从 Blueprint 调用一个命名的叙事触发器，并通过将新的区段 ID 打印到屏幕上来确认区段变化。

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

### 我们将构建什么

一个绑定了 **接收叙事章节时** 在其 `UConvaiChatbotComponent`，然后调用 **调用叙事设计触发器** 当玩家按下按键时。一个 **打印字符串** 节点和 **输出日志** 用于确认章节已切换。

### 前提条件

* 已安装 Convai Unreal Engine 插件并配置 API 密钥。请参阅 [安装 Convai 插件](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/install-the-convai-plugin.md) 并 [配置 API 密钥](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/configure-your-api-key.md).
* 一个角色 `Actor` 蓝图，带有一个 `UConvaiChatbotComponent` (`Convai Chatbot`) 和 `CharacterID` 设置为有效 ID。请参阅 [添加你的第一个 Convai 角色](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/add-your-first-convai-character.md).
* 在 Convai 控制面板中为该角色 ID 配置至少一个区段和一个触发器。请参阅 [叙事设计 | Playground](https://docs.convai.com/api-docs/zh/convai-playground/character-customization/narrative-design.md).

打开 Unreal Engine 前，请在控制面板中确认：

| 检查项   | 验证内容                                                     |
| ----- | -------------------------------------------------------- |
| 图表已创建 | 该角色至少有一个区段和一个出站触发器。                                      |
| 触发器名称 | 请准确复制触发器名称——区分大小写。                                       |
| 可到达的边 | 触发器是角色起始所在区段的一条出边。                                       |
| 角色 ID | 该 `CharacterID` 在 `UConvaiChatbotComponent` 与控制面板中的角色匹配。 |

### 构建蓝图

{% stepper %}
{% step %}

#### 打开角色 Blueprint

打开包含以下组件的 Actor 蓝图： `UConvaiChatbotComponent`。在 **事件图表**中，点击 **组件** 面板中的组件以选中它。
{% endstep %}

{% step %}

#### 绑定 On Narrative Section Received

将 `UConvaiChatbotComponent` 引用从 **组件** 面板拖入事件图表。从组件引脚拖出，然后搜索 **On Narrative Section Received**。选择 **Assign On Narrative Section Received** 以创建绑定事件节点。

生成的事件节点会显示两个输出引脚： `Chatbot Component` (`UConvaiChatbotComponent` 引用）和 `Narrative Section ID` (`FString`).
{% endstep %}

{% step %}

#### 打印章节 ID

连接一个 **Print String** 节点到事件的执行引脚。将 `Narrative Section ID` 输出引脚接入 **Print String**的 `In String` 输入。每当 Convai 推进故事图时，这都会将新的章节 ID 打印到屏幕上。
{% endstep %}

{% step %}

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

在事件图表中添加一个 **键盘** 事件节点（例如 `F` 键）。将 `UConvaiChatbotComponent` 引用从 **组件** 面板拖出，并从该引用调用 **Invoke Narrative Design Trigger** 。

将 `Trigger Name` 设置为 Convai 控制面板中显示的触发器名称（必须完全一致），例如 `start_inspection`）。连接 **Pressed** 键盘事件的执行引脚连接到 **调用叙事设计触发器**.

{% hint style="info" %}
`bAutoInitializeSession` 默认为 `true` ，已启用 `UConvaiChatbotComponent`，因此会话会在 **Begin Play**时开启。如果在会话连接成功前按下按键，触发器会加入 `PendingTriggers` ，并在连接建立后重放。
{% endhint %}
{% endstep %}

{% step %}

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

点击 **在编辑器中运行**。会话连接成功后，按下你绑定的按键。观察屏幕上是否打印出一个区段 ID 字符串。

如果触发器名称与角色当前区段中可触发的触发器相匹配，Convai 会推进故事图，并且 **接收到叙事区段时** 会以新的 `Narrative Section ID`.

如果没有打印内容，请参阅 [叙事设计故障排除](https://docs.convai.com/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" %}
[叙事触发器](https://docs.convai.com/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" %}
[模板键](https://docs.convai.com/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" %}
[叙事设计的工作原理](https://docs.convai.com/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" %}
[排查叙事设计问题](https://docs.convai.com/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 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/narrative-design/narrative-design-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.
