> 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/unity-plugin/adding-npc-to-npc-conversation.md).

# 添加 NPC 对 NPC 对话

## **步骤 1：设置 Convai NPC**

1. **前往你的 Convai NPC**:
   * 选择你想要包含在对话中的 NPC。
2. **启用群组 NPC 控制器**:
   * 点击 `群组 NPC 控制器` 检查器面板中的复选框。
   * 点击 `应用更改` 以添加群组 NPC 控制器脚本。<br>

     <figure><img src="https://lh7-us.googleusercontent.com/JUlMGlkifNW_8JQ1FJO-55h_c754kh1kgepM0gJFaZ0Ek6FNUyCLvrn2EqtfDORjY8k6-2fsSTzry9LLEWihFhnv0ZGFBSMFIkQ6xGFd0qk9z87p4pz91O6Bvc1vzMqBi_hpxaTvPwvjTMg70iaAm9U" alt=""><figcaption></figcaption></figure>
3. **创建或查找对话气泡预制体**:
   * 创建一个新的对话气泡预制体，或使用其中提供的预制体 `预制体` 文件夹。<br>

     <figure><img src="/files/394e74290842a248e5772348d3e73c40f164bb3f" alt=""><figcaption></figcaption></figure>
4. **附加所需组件**:
   * 添加对话气泡预制体和玩家变换（可选，若未提供则默认使用主摄像机）。
   * 设置对话距离阈值变量（将其设为 0 可禁用此功能，这意味着无论玩家距离多远，NPC 与 NPC 的对话都将始终发生）。<br>

     <figure><img src="/files/400cfe2a8af2555f60b29467a406893fd691e68a" alt=""><figcaption></figcaption></figure>
5. **添加相关组件**:
   * 向 Convai NPC 添加诸如口型同步、眼睛和头部跟踪、角色眨眼等组件。

## **步骤 2：设置 NPC 管理器**

1. **创建一个 NPC 对 NPC 管理器 GameObject**:
   * 添加一个空的 GameObject，并将其重命名为 `NPC 对 NPC 管理器` （可选）。
2. **添加 NPC2NPC 对话管理器脚本**:
   * 附加 `NPC2NPCConversationManager` 脚本到该 GameObject。<br>

     <figure><img src="/files/a261f4472d6f7d1a0f2a37df5371f51e6a78ae8b" alt=""><figcaption></figcaption></figure>
3. **配置 NPC 组列表**:
   * 在 `NPC 组列表`，点击 `+` 图标以添加新的列表元素。
   * 添加你想包含在群组对话中的 NPC。
   * 设置群组讨论主题。<br>

     <figure><img src="/files/091fbace0fbc6e0f1e053c88c71cf3ece80dcae3" alt=""><figcaption></figcaption></figure>
4. 完成 NPC 配置后
   * 将 NPC 彼此靠近
   * 播放该内容，确保一切按预期运行。<br>

     <figure><img src="/files/c5062abaa8e7c766a004a2690a08f83e241979f3" alt=""><figcaption></figcaption></figure>

按照这些步骤，您就可以在由 Convai 驱动的应用中设置和管理 NPC 与 NPC 之间的对话。有关进一步自定义和集成，请参考完整的实现代码，并根据您的具体用例进行相应调整。


---

# 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/unity-plugin/adding-npc-to-npc-conversation.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.
