> 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 角色对玩家眼神接触的投入强度，从自然行为到永久锁定。

通过设置以下内容来配置 Convai 角色对玩家眼神接触的投入程度 `GazeEyeContactMode`, `GazeFocusFidelity`，以及玩家锚点瞄准模式为 `ConvaiGazeController`。当默认的按状态行为对主持人或 kiosk 角色来说过于温和，或者当角色需要看向主摄像机以外的对象时，请使用此页面。

### 前提条件

* 具有以下设置的角色 `ConvaiGazeController` 已添加——参见 [凝视快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/quick-start.md).

### 选择眼神接触模式

“ **眼神接触** 下拉菜单位于 `ConvaiGazeController` Inspector 的 Targeting 部分是产品级开关，用于控制角色对玩家投入的强度。可在此处设置，或在运行时通过 `gaze.EyeContactMode`:

| 模式                 | 对话状态中的行为                                               | 在……期间的行为 `空闲`                | 用于                             |
| ------------------ | ------------------------------------------------------ | ---------------------------- | ------------------------------ |
| `自然` （默认）          | 遵循配置文件按对话状态划分的策略表——经过编写、变化多样的投入。                       | 环境性存在感；玩家不是有效目标。             | 具有精心设定个性的角色，应该看起来自然，而不是僵硬固定。   |
| `SpeakingFocus`    | 只有在角色实际发声或对话状态为 `说话中`时，才完全投入到玩家。倾听和思考仍由配置文件驱动。         | 环境性存在感；玩家不是有效目标。             | 在说话时应专注、其他时候则应表现自然的主持人和对话 NPC。 |
| `ConversationLock` | 完全投入——投入度最大，不主动移开视线，头部充分参与，允许身体转向——在所有非`空闲` 状态时为 True。 | 环境性存在感；玩家不是有效目标。             | 绝不能在对话中途移开视线，但在对话间仍有闲置动作的角色。   |
| `AlwaysLock`       | 完全投入，与……相同 `ConversationLock`.                         | 完全投入——即使在……期间，玩家仍是有效目标 `空闲`. | 绝不应移开视线的自助终端迎宾和演示台。            |

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

更改 `EyeContactMode` 在运行时会平滑过渡到新的投入级别，而不是突然跳变。

{% hint style="warning" %}
当 `ConversationLock` 或 `AlwaysLock` 处于激活状态时，配置文件的按状态策略表会在投入和回避方面被绕过。如果你想要自然的思考回避和说话规划停顿，请保持为 `自然` 或使用 `SpeakingFocus` 改为此项。
{% endhint %}

眼神接触锁定还会覆盖 `AttendToSpeaker` （ **听众关注** 用于在多角色对话中将角色转向当前发言者的设置）：当 `ConversationLock` 或 `AlwaysLock` 处于激活状态时，角色绝不会转身去跟随其他说话者的轮次，无论 **听众关注** 设置为何值。该锁定承诺会持续看着玩家，并且它优先。参见 [对话注意力](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/profile-reference.md#conversation-attention).

### 设置焦点保真度

`GazeFocusFidelity` 控制 `ConversationLock`, `AlwaysLock`，或 `SpeakingFocus` 在这些模式之一激活后，投入程度对玩家锚点的保持精确度：

| 值         | 行为                                                 |
| --------- | -------------------------------------------------- |
| `社交` （默认） | 保留轻微的注视移动和有社交意义的头部动作，同时仍将玩家视为对话目标。推荐用于对话角色。        |
| `精确`      | 在焦点激活期间抑制主动移开视线和注视偏移。眨眼、眼睑、瞳孔、辐辏以及符合人体结构的身体转向仍会表现。 |

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

`社交` 保真度仍允许显式的 `GazeAt()` 请求抢占该锁定，因此先看向某处再执行动作的复合行为仍可正常工作。 `精确` 保真度会拒绝脚本化的 `GazeAt()` 默认情况下；启用 `AllowScriptedOverridesDuringExactFocus` ，如果某个编写的序列无论如何都需要抢占它。参见 [脚本化注视](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/gaze/scripted-gaze.md).

### 选择锚点的瞄准方式

`GazeAnchorAimMode` 控制角色实际瞄准玩家锚点上的哪个位置，与当前激活的眼神接触模式无关：

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

在……上设置模式 `ConvaiGazeController` 为 `PlayerAnchorAimMode`，并设置 `PlayerAnchorAimOffset` 在使用时 `LocalOffset`. `LocalOffset` 建议用于旋转过的自定义锚点，或 XR / 过场动画装置，其中 `自动`的摄像机位置假设不适用。

对于分屏、多人或过场动画设置，在这些情况下角色不应跟随 `Camera.main`，请设置 `PlayerAnchorOverride` 为它应当视作玩家的那个变换。

### 验证该设置

进入 Play 模式并开始对话。使用 `ConversationLock` 或 `AlwaysLock` 设置后，角色应在每个对话节拍中都保持眼神接触，不会移开视线；而使用 `AlwaysLock` 时，它也应在 `空闲`期间保持接触。使用 `自然` 或 `SpeakingFocus`时，接触应在……期间明显减弱 `思考中` 以及空闲时段。

### 下一步

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

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

{% content-ref url="/pages/beb7fd6775b7e9b4da287a76d337e2f0e2a2b17f" %}
[排查视线问题](/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 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/embodiment/gaze/configure-eye-contact.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.
