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

# 选择目标模式

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

设置 `ConversationTargetingMode` 时 `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="Proximity" %}
`Proximity` 会将话题指向最近的角色，而不管玩家正在看哪里。

使用 `Proximity` 适用于俯视和第三人称游戏，其中相机并不是玩家的视线——例如等距训练模拟或带自由相机的第三人称场景，在这种情况下 `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 %}

### 验证模式是否生效

在已注册两个或更多角色的情况下进入播放模式。在……下 `LookAt` 或 `Proximity`，在角色之间移动玩家的视角或位置，并确认对话会随之跟随。选择 `ConvaiManager` 在播放模式下的 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 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/conversation-targeting/choose-a-targeting-mode.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.
