> 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-unity-sdk/features/multi-character-sessions/quick-start.md).

# 构建你的第一个多角色会话

向一个可用的 Unity 场景中添加第二个 Convai 角色，并确认房间允许你通过看向他们中的任意一个来与其对话。

添加第二个 `ConvaiCharacter` 到一个已经有一个可正常工作的角色的场景中，并确认房间会根据你的视线方向让你与任意一个角色对话。这里没有需要开启的多角色模式，没有需要添加的组件，也没有需要填写的字段：房间会自动容纳已加载场景中的每一个处于激活状态的 Convai 角色。

### 前置条件

* [ ] 一个已配置好可正常工作的单角色设置的 Unity 场景： `ConvaiManager`, `ConvaiRoomManager`, `ConvaiPlayer`，以及一个 `ConvaiCharacter` 它在播放模式下已经会回应。
* [ ] 来自你的第二个角色 ID [Convai 仪表板](https://convai.com).

### 设置并测试第二个角色

{% stepper %}
{% step %}

#### 添加第二个角色

将第二个可正常工作的角色拖入场景——如果你的项目自带第二个角色预制体，就使用它；或者复制你现有角色的 `GameObject`。复制会保留原角色拥有的每一个组件，包括 `ConvaiCharacter`，并且也会沿用原角色的 Character ID——复制体不会拥有自己的 Character ID。

选中新角色的 `ConvaiCharacter` 组件。其 Inspector 显示 **另一个角色已使用此 Character ID** ，会立即显示在最上方、所有其他部分之上，因为两个角色不能共用同一个；在它们共用时，房间会拒绝连接。把第二个角色自己的 Character ID 从 [Convai 仪表板](https://convai.com) 拖入 **角色 ID** 字段中粘贴进去，提示信息就会消失。
{% endstep %}

{% step %}

#### 确认场景设置

选中 `GameObject` 包含 `ConvaiManager` 并打开其 Inspector。 **场景设置** 部分现在显示 **场景中的角色** 为 `2` 和 **加入房间** 为 `全部 2 个` ——两个角色都会计入下一次房间连接。

向下滚动到 **加入房间的角色**。它会为每个角色列出一行，并带有已勾选的复选框，因为每个角色默认都会加入——无需手动启用任何东西。如果有任何一个复选框被取消勾选，请点击 **包括所有人** 让两者都加入。
{% endstep %}

{% step %}

#### 将“玩家与谁对话”保留为“看向对象”

在为房间选择两个角色后， `ConvaiManager` Inspector 会添加一个 **玩家与谁对话** 部分。将 **选择方式** 保持默认值 **看向对象** ——它会测量玩家摄像机到每个角色头部的角度，因此不需要碰撞体、不需要图层遮罩，也不需要输入连线。这就是为什么这里没有其他设置项。
{% endstep %}

{% step %}

#### 进入播放模式并与每个角色交谈

进入播放模式。看向第一个角色并开始说话或输入——它会回应。

转向第二个角色并再次说话。对话会转移到它：第一个角色的回合结束，第二个角色回应。
{% endstep %}
{% endstepper %}

### 验证设置

{% hint style="success" %}
**成功：** 两个角色都会根据你看向谁来回应，而不是根据谁先连接或谁最后说话。
{% endhint %}

选择 `ConvaiManager` 在仍处于播放模式时再次查看。它的 **实时** 部分是确认两个角色确实正在共享同一个房间的最快方式：

* **房间中的角色** 显示房间实际打开时对应的数量。
* **正在对话对象** 显示你当前正在对话的角色，并会随着你转头而更新。
* **玩家可以说话** 显示 **是** 一旦该角色能听到你——它会显示 **还没有——该角色仍在加入** 房间后的短暂时刻。
* **房间容纳** 显示 **多个角色** 在房间中的角色数量超过一个之后。
* **房间名册**，在其下方，每个角色占一行。你正在对话的角色会标记为 `· 已对话`，而当前能够继续对话的角色会显示为 `就绪`.

如果 **正在对话对象** 如果在你看向另一个角色时它从未变化，请检查 **范围** 和 **观察角度** 在 **玩家与谁对话** ，然后确认第二个角色在 **房间名册** 中的行确实显示为 `就绪`.

### 下一步

{% content-ref url="/pages/1de47e20d64086de6ea2148c4871a665eec92182" %}
[多角色会话工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/how-multi-character-sessions-work.md)
{% endcontent-ref %}

{% content-ref url="/pages/6481618ebe16f2ac14d3eecace53ed97c7f369d1" %}
[角色身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/character-identity.md)
{% endcontent-ref %}

{% content-ref url="/pages/ebc0a4d0906b09a678bb072ecb66e021541e3730" %}
[选择目标模式](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/choose-a-targeting-mode.md)
{% endcontent-ref %}

{% content-ref url="/pages/2c6d63cffd7b1ec0697bd7dd2aa8bd901ef1f717" %}
[排查多角色会话问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/troubleshooting.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-unity-sdk/features/multi-character-sessions/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.
