> 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/tune-targeting.md).

# 调整对话目标选择

调整范围、视角、切换余量和切换延迟，使对话目标选择与角色之间的距离相匹配。

调整 `ConversationTargetingOptions` 时 `ConvaiManager` 当默认范围、角度或切换行为不适合你的场景时——例如角色站得很近，导致对话过于容易在他们之间切换，或者对于宽屏来说观看角度太窄。请在选择模式后使用此页面 [选择一种目标模式](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/choose-a-targeting-mode.md).

### 前提条件

* 已选择一个目标模式（`LookAt` 或 `Proximity`)
* 熟悉“资格与切换”分离的概念 [对话定位的工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/how-conversation-targeting-works.md)

### 了解每个数值控制什么

`MaxDistance` 和 `MaxAngle` 决定谁是 **有资格的** 才能被对话所指向。 `SwitchMargin` 和 `SwitchDelaySeconds` 决定一旦符合资格，有资格的竞争者会多愿意接管对话，并用于防止目标在两个候选者之间闪烁切换。当前一个角色完全无法被指向时，使用第一组；当对话切换过于容易或不够容易时，使用第二组。

| 字段                   | 默认            | 控制项                                                                                           |
| -------------------- | ------------- | --------------------------------------------------------------------------------------------- |
| `MaxDistance`        | `30` 米        | 角色离得多远仍可被视为有资格。                                                                               |
| `MaxAngle`           | `35` 度        | 以视线方向为基准，从视野中心偏离多少角度时角色仍可被视为有资格—— `35` 会形成一个 70 度的锥形范围。                                       |
| `SwitchMargin`       | `10` 度        | 另一位角色需要比当前目标高出多少分，对话才会切换到他们。适用于 `LookAt` 仅限，因为它以度为单位。                                         |
| `SwitchDelaySeconds` | `0.2` seconds | 另一个角色必须保持最佳选择多久，对话才会切换到他们。在 `Proximity`下，这就是区分两个等距角色的因素，因为 `SwitchMargin` 对于以米为单位测量的规则来说没有意义。 |

### 调整这些数值

{% tabs %}
{% tab title="Inspector" %}
选择 `ConvaiManager` GameObject，然后打开 **玩家与谁对话**。调整 **范围（米）**, **视线角度（度）**, **切换余量（度）**&#x4EE5;及 **切换延迟（秒）**.
{% endtab %}

{% tab title="C#" %}

```csharp
ConvaiManager manager = ConvaiManager.ActiveManager;
manager.ConversationTargeting.MaxDistance = 15f;
manager.ConversationTargeting.MaxAngle = 20f;
manager.ConversationTargeting.SwitchMargin = 15f;
manager.ConversationTargeting.SwitchDelaySeconds = 0.4f;
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
每个字段都会限制在其各自的有效范围内： `MaxAngle` 介于 `1` 和 `180` 度， `SwitchMargin` 介于 `0` 和 `90` 度，以及 `MaxDistance` 和 `SwitchDelaySeconds` 最小为 `0`。将值设为该范围之外时，会将其夹紧而不是抛出异常。
{% endhint %}

### 验证更改

在已注册两个或更多角色的情况下进入播放模式。移动玩家的视角或位置，并确认目标会在你预期的时刻切换——范围更窄时更严格， `MaxAngle`切换更慢时更宽松， `SwitchDelaySeconds`检查 Inspector 的 Live 部分，查看当前被指向的角色以及上一次决策背后的判断结果。 `ConvaiManager` 常见调整

### 对话在两个相邻角色之间闪烁切换。

**先调整第一项，** 先提高 `SwitchMargin` 然后 `SwitchDelaySeconds` 如果闪烁仍然持续。

**只是看向某个角色并不会把对话切换给他们。** 他们的距离或角度可能超出了 `MaxDistance` 或 `MaxAngle` ——把限制他们的那个值调大。

**在扫视房间时，目标切换得过于积极。** 先提高 `SwitchDelaySeconds` 这样，一次掠过的视线就不再会被算作在指向它经过的每个角色。

### 下一步

{% content-ref url="/pages/8ebdb90f75876aa6a33c36e080adab2e377b1140" %}
[对话目标选择参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/targeting-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/95abf0b99847b20d9974a37b48ecd2a7c47c4c77" %}
[对话目标选择故障排查](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/conversation-targeting/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/conversation-targeting/tune-targeting.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.
