> 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/conversation-targeting/choose-a-targeting-mode.md).

# 选择目标模式

选择与相机和控制方案匹配的对话目标选择模式，以便正确的角色响应玩家。

设置 `会话目标选择模式` 在 `ConvaiManager` 这样 SDK 就能在同一房间中有多个角色时选对角色——适用于第一人称视角的模式，不适用于俯视摄像机或对话菜单。当前页面适用于你有两个或更多 `ConvaiCharacter` 场景中的组件，并且需要决定玩家如何与其中一个交互。

### 前置条件

* 已安装并配置好 Convai Unity SDK
* 两个或更多 `ConvaiCharacter` 已在场景中注册的组件
* 熟悉该模型中的 [对话目标选择的工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/how-conversation-targeting-works.md)

### 选择一种模式

`ConvaiManager` 在下提供三种模式 **Convai Manager → 玩家与谁对话 → 由以下方式决定**。当场景中可供选择的角色超过一个时，该部分会出现在 Inspector 中。

{% tabs %}
{% tab title="注视（默认）" %}
`LookAt` 会选择最接近玩家视野中心的角色。它会根据相对于视线方向的角度为每个符合条件的角色打分，并以距离作为平分时的决胜因素，因此它在鼠标、手柄、触摸屏和头戴式显示设备上都以相同方式工作——它读取的是摄像机，而不是输入设备。

使用 `LookAt` 适用于第一人称和 VR 场景，以及任何摄像机方向就是玩家视线的场景。
{% endtab %}

{% tab title="接近" %}
`接近` 会选择最近的角色，而不管玩家在看哪里。

使用 `接近` 适用于俯视和第三人称游戏，此时摄像机并不是玩家的视线——例如等距训练模拟或使用自由摄像机的第三人称场景，在这些场景中 `LookAt` 它会把摄像机当前指向的角色当作对话对象，而不是玩家实际靠近的角色。
{% endtab %}

{% tab title="手动" %}
`手动` 只有当游戏调用 `ConvaiManager.TalkTo`。不会有任何自动切换。

使用 `手动` 适用于对话菜单、任务步骤和过场动画，在这些场景中，由游戏——而不是玩家的视角或位置——来决定当前在与谁对话。参见 [脚本化对话目标](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/script-the-conversation-target.md).
{% endtab %}
{% endtabs %}

### 设置模式

{% tabs %}
{% tab title="Inspector" %}
选中 `ConvaiManager` GameObject，打开 **玩家与谁对话**，然后从 **选择方式**.
{% endtab %}

{% tab title="C#" %}

```csharp
ConvaiManager manager = ConvaiManager.ActiveManager;
manager.ConversationTargeting.Mode = ConversationTargetingMode.Proximity;
```

{% endtab %}
{% endtabs %}

### 验证模式是否生效

在已注册两个或更多角色的情况下进入 Play 模式。在 `LookAt` 或 `接近`，在角色之间移动玩家的视角或位置，并确认对话会随之切换。选择 `ConvaiManager` 在 Play 模式下的 Inspector 中，并检查 Live 部分——其中会显示当前正在对话的角色，以及上一次目标选择决策背后的判定结果。

{% hint style="success" %}
Live 部分会在你在角色之间移动时报告当前对话对象发生变化。如果它始终不变，请参见 [对话目标选择故障排查](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/troubleshooting.md).
{% endhint %}

### 下一步

{% content-ref url="/pages/8494a4ba27fe2362e8453d31e511d63dee5842c1" %}
[调整对话目标选择](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/tune-targeting.md)
{% endcontent-ref %}

{% content-ref url="/pages/f411a648fdc7e99258a645a2b4b897adb9e6a570" %}
[编写对话目标脚本](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/script-the-conversation-target.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/conversation-targeting/choose-a-targeting-mode.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.
