> 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` 它在 Play 模式下已经会回应。
* [ ] 来自你的第二个角色 ID [Convai 仪表板](https://convai.com).

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

{% stepper %}
{% step %}

#### 添加第二个角色

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

选择新角色的 `ConvaiCharacter` 组件。其 Inspector 会显示 **另一个角色已使用此 Character ID** 会立即显示在所有其他部分之上，因为两个角色不能共用同一个 ID，否则 [Convai 仪表板](https://convai.com) 将第二个角色自己的 Character ID 从 **Character ID** 字段中，消息就会消失。
{% endstep %}

{% step %}

#### 确认场景设置

选择 `游戏对象` 持有 `ConvaiManager` 并打开其 Inspector。该 **Scene Setup** 部分现在显示 **场景中的角色数** 为 `2` 和 **加入房间** 为 `共 2 个` ——两个角色都会计入下一次房间连接。

向下滚动到 **加入房间的角色**。每个角色都会占一行，并带有勾选框，因为默认情况下每个角色都会加入——无需手动启用任何内容。如果任一勾选框被取消，请点击 **包含所有人** 以发送两者。
{% endstep %}

{% step %}

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

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

{% step %}

#### 进入 Play 模式并分别与每个角色对话

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

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

### 验证设置

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

选择 `ConvaiManager` 在仍处于 Play 模式时再次……其 **实时** 部分是确认两个角色确实共用同一房间的最快方式：

* **房间中的角色** 显示房间实际打开时的角色数量。
* **正在对话** 显示你当前正在对话的角色名称，并会随着你转头而更新。
* **玩家可以说话** 显示 **是** 一旦该角色能听见你——它会显示 **还未就绪——该角色仍在加入中** 在它刚加入房间后的短暂时刻。
* **房间容纳** 显示 **多个角色** 一旦房间中角色数量超过一个。
* **房间成员列表**，下方会按角色逐行列出。你正在对 `· 正在对话`，而当前能够继续对话的角色会显示 `就绪`.

如果 **正在对话** 当你看向另一个角色时始终不变，请检查 **范围** 和 **视角** 中的 **玩家与谁对话** 首先，然后确认第二个角色在 **房间成员列表** 实际显示为 `就绪`.

### 下一步

{% 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
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=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
