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

# 多角色会话

查找有关在同一个 Unity 场景中运行多个 Convai 角色、选择与玩家对话的角色，以及测试共享房间的指南。

多角色会话是一个 Unity 场景，其中有两个或更多 `ConvaiCharacter` 组件同时处于活动状态，并与 Convai 共处一个房间。玩家一次与一个角色对话，SDK 会判断玩家在对谁说话——无需切换模式、添加组件或填写字段。通过以下页面，你可以在已运行的场景中添加第二个角色，了解房间如何判断玩家在与谁对话，并学习在房间中有多个角色时如何正确识别每个角色。

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>多角色会话的工作原理</strong><br>了解房间如何根据场景中的活动角色构建，以及如何判断玩家在与谁对话。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/how-multi-character-sessions-work.md">多角色会话工作原理</a></td></tr><tr><td><strong>构建你的第一个多角色会话</strong><br>在已运行的场景中添加第二个角色，并确认房间会响应玩家当前注视的角色。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/quick-start.md">构建你的第一个多角色会话</a></td></tr><tr><td><strong>角色身份</strong><br>为房间中的每个角色分配独立的 Character ID，并了解两个角色共用同一 ID 时会发生什么。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/character-identity.md">角色身份</a></td></tr><tr><td><strong>多角色示例</strong><br>导入随附的示例场景，查看多个角色、交互目标选择和转录界面如何协同工作。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/multi-character-sample.md">多角色示例</a></td></tr></tbody></table>

### 多角色场景会引出的两个问题

在场景中添加第二个角色，会引出单角色场景中从未遇到的两个问题：玩家正在和谁说话？玩家现在能否说话？这两个问题分别由各自的功能领域负责。

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>对话目标选择</strong><br>了解 SDK 如何判断玩家在与哪个角色对话，以及如何通过脚本或调整参数来控制这一判断。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting.md">对话目标选择</a></td></tr><tr><td><strong>对话可用性</strong><br>了解被选中的角色是否已能听到玩家说话，以及如何根据此状态控制自己的 UI。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-availability.md">对话可用性</a></td></tr></tbody></table>

### 后续步骤

首先阅读 [构建你的第一个多角色会话](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/quick-start.md) ，在场景中添加第二个角色并确认房间能够连接到该角色；然后阅读 [角色身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/character-identity.md) ，再为多个角色分配 Character ID。

{% content-ref url="/pages/1de47e20d64086de6ea2148c4871a665eec92182" %}
[多角色会话工作原理](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/multi-character-sessions/how-multi-character-sessions-work.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.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.
