> 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/embodiment/gaze/configure-eye-contact.md).

# 配置眼神接触

配置 Convai 角色对玩家眼神接触的投入强度，从自然行为到永久锁定。

通过设置 `GazeEyeContactMode`, `GazeFocusFidelity`以及在 `ConvaiGazeController`上设置玩家锚点瞄准模式，来配置 Convai 角色对玩家眼神接触的投入程度。如果默认的逐状态行为对主持人或信息亭角色来说不够坚定，或者角色需要注视主摄像机以外的对象，请使用本页面。

### 前提条件

* 已添加 `ConvaiGazeController` 的角色 — 请参阅 [凝视快速入门](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/quick-start.md).

### 选择眼神接触模式

&#x20;**眼神接触**  下拉菜单位于 `ConvaiGazeController` 检查器的 Targeting（目标）部分，是控制角色对玩家投入程度的产品级开关。可在此处设置，也可在运行时通过 `gaze.EyeContactMode`:

| 模式                 | 对话状态下的行为                                                   | 处于 `Idle`           | 适用场景                               |
| ------------------ | ---------------------------------------------------------- | ------------------- | ---------------------------------- |
| `Natural` （默认）     | 遵循配置文件中针对各对话状态的策略表 — 按预设方式呈现多样化的互动。                        | 环境闲置状态；玩家不是有效目标。    | 具有预设个性、应表现得自然而非始终注视玩家的角色。          |
| `SpeakingFocus`    | 仅当角色实际正在说话，或对话状态为 `Speaking`时，才会全程注视玩家。聆听和思考时仍由配置文件控制。     | 环境闲置状态；玩家不是有效目标。    | 在说话时应专注于玩家、其他时候则保持自然表现的主持人和对话 NPC。 |
| `ConversationLock` | 完全投入 — 互动程度最高，不会有意移开视线，头部充分参与，并允许转动身体 — 在所有非`Idle` 状态下均如此。 | 环境闲置状态；玩家不是有效目标。    | 对话过程中绝不能移开视线，但对话间隙仍应有闲置状态表现的角色。    |
| `AlwaysLock`       | 完全投入，与 `ConversationLock`.                                 | 完全投入 — 即使处于 `Idle`. | 绝不移开视线的信息亭接待角色和演示展位角色。             |

```csharp
ConvaiGazeController gaze = GetComponent<ConvaiGazeController>();
gaze.EyeContactMode = GazeEyeContactMode.ConversationLock;
```

更改 `EyeContactMode` 会平滑过渡到新的投入程度，而不是突然切换。

{% hint style="warning" %}
当 `ConversationLock` 或 `AlwaysLock` 处于活动状态时，会绕过配置文件针对投入和厌恶状态设置的策略表。如果你希望在思考时自然地移开视线，并在说话规划时自然地停顿，请继续使用 `Natural` 或改用 `SpeakingFocus` 。
{% endhint %}

眼神接触锁定还会覆盖 `AttendToSpeaker` （即 **关注说话者** 设置；在多角色对话中，此设置会让角色转向当前发言者）：当 `ConversationLock` 或 `AlwaysLock` 处于活动状态时，无论 **关注说话者** 设置为何，角色都不会转开视线去跟随其他发言者。锁定意味着角色会始终注视玩家，并且优先级最高。另请参阅 [对话中的注意力](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/profile-reference.md#conversation-attention).

### 设置注视保真度

`GazeFocusFidelity` 用于控制 `ConversationLock`, `AlwaysLock`或 `SpeakingFocus` 模式处于活动状态后，角色对玩家这一注视目标的坚持程度：

| 值             | 行为                                                          |
| ------------- | ----------------------------------------------------------- |
| `Social` （默认） | 保留细微的注视移动和符合社交习惯的头部动作，同时仍将玩家视为对话对象。推荐用于对话角色。                |
| `Exact`       | 在注视焦点处于活动状态时，抑制有意的移开视线和注视偏移。眨眼、眼睑、瞳孔、辐辏以及符合解剖结构的身体转动仍会照常播放。 |

```csharp
gaze.FocusFidelity = GazeFocusFidelity.Social;
```

`Social` 保真度仍允许显式的 `GazeAt()` 请求抢占锁定，因此，先看向某处再执行动作的组合操作仍能正常工作。 `Exact` 保真度默认会拒绝脚本化的 `GazeAt()` ；如果编写的序列仍需抢占锁定，请启用 `AllowScriptedOverridesDuringExactFocus` 。另请参阅 [脚本化注视](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/scripted-gaze.md).

### 选择注视目标的瞄准方式

`GazeAnchorAimMode` 用于控制角色实际瞄准玩家注视目标上的位置，与当前启用的眼神接触模式无关：

| 值                | 行为                                                    |
| ---------------- | ----------------------------------------------------- |
| `Auto` （默认）      | 当注视目标是摄像机时，使用摄像机的精确位置；当目标不是摄像机时，则按常规将瞄准线抬高。           |
| `ExactTransform` | 使用注视目标的精确世界位置，不进行抬高。                                  |
| `LocalOffset`    | 对 `PlayerAnchorAimOffset` 从锚点局部空间转换到世界空间，因此注视点会随锚点移动。 |

将 `ConvaiGazeController` 的模式设为 `PlayerAnchorAimMode`，并在使用 `PlayerAnchorAimOffset` 时将其设为 `LocalOffset`. `LocalOffset` 。对于旋转过的自定义锚点或 XR、过场动画 Rig，推荐使用此模式，因为 `Auto`对摄像机位置的假设并不适用。

对于分屏、多人游戏或过场动画设置，如果不希望角色跟随 `Camera.main`，请将 `PlayerAnchorOverride` 设为应视为玩家的 Transform。

### 验证设置

进入播放模式并开始对话。设置为 `ConversationLock` 或 `AlwaysLock` 后，角色在对话的每个阶段都应保持眼神接触，不会移开视线；设置为 `AlwaysLock` 时，在 `Idle`期间也应保持眼神接触。设置为 `Natural` 或 `SpeakingFocus`后，在 `Thinking` 和闲置期间，眼神接触应明显变得柔和。

### 后续步骤

{% content-ref url="/pages/fab0d9cdf9524b6f370dae71380fef0d847f60e9" %}
[Gaze 配置文件参考](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/profile-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/0c6914a280e6fc584ecfe676625883fc201033e3" %}
[脚本控制的视线](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/scripted-gaze.md)
{% endcontent-ref %}

{% content-ref url="/pages/beb7fd6775b7e9b4da287a76d337e2f0e2a2b17f" %}
[排查视线问题](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/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 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/embodiment/gaze/configure-eye-contact.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.
