> 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-unreal-engine-plugin/features/spatial-awareness/merge-same-named-objects.md).

# 合并同名对象

合并一堆同名对象，例如一堆箱子，使角色将整组视为一个逻辑整体。

默认情况下， `UConvaiObjectComponent` 共享同名的实例会保持彼此独立——第二个及之后的重复项会获得名称后缀，因此 AI 仍可逐个单独指向它们。对于角色应视为一个整体的一堆道具——例如一叠箱子、一排压力板——请开启 **与同名对象合并** 改为。 本指南会合并一组同名对象，并展示如何在叠加层中确认合并。

### 先决条件

* 关卡中两个或更多 Actor，每个都具有一个 `UConvaiObjectComponent`，共享相同的 `名称` 在 **对象条目** （不区分大小写）。
* 项目已启用空间感知——参见 [空间感知快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/spatial-awareness/spatial-awareness-quick-start.md).

### 合并会改变什么

开启 **与同名对象合并** 在集合中的每个成员上进行此设置，会改变 AI 对它们的感知方式：

* 其位置是所有成员位置的平均值。
* 注视任一成员都会同时高亮整个集合，除非你将某个成员排除在外。
* AI 会收到整个集合的一份描述——即第一个非空的 **描述** 成员中的内容，因此你只需要在其中一个上填写即可。
* 成员彼此不会添加不同的后缀——它们是故意共用一个名称的。如果该名称仍与另一个独立的已合并集合或未合并对象冲突，那么整个已合并集合会获得一个共同的后缀，以便仍可被寻址。

保持 **与同名对象合并** 关闭（默认）可让同名对象保持独立，并通过 **重复名称后缀样式** 而是——参见 [空间感知设置参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/spatial-awareness/spatial-awareness-reference.md).

### 合并一组对象

{% stepper %}
{% step %}

#### 为每个成员赋予相同的 Object Entry 名称

在每个 `UConvaiObjectComponent` 集合中的项上，展开 **对象条目** 并设置相同的 **名称** ——例如， `板条箱` 并将其设置到堆中的每个板条箱上。
{% endstep %}

{% step %}

#### 开启“与同名对象合并”

在这些组件中的每一个上，展开 **Convai | 对象 | 分组** 并勾选 **与同名对象合并** (`bMergeWithSameNamedObjects`）。默认未勾选。
{% endstep %}

{% step %}

#### 如果有不止一组，请设置合并组索引

如果关卡中有两堆彼此独立、但都共享同一个对象名称并且应分别合并，请将 **合并组索引** (`MergeGroupIndex`，默认 `0`）在每一堆的成员上设为不同的值。对象只有在同时共享相同的 **名称** 以及相同的 **合并组索引**。请将其保持为 `0` 用于单堆的常见情况。
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**合并组索引** 只有在……时才生效 **与同名对象合并** 开启时才有效——否则会变灰。
{% endhint %}

### 选择高亮行为

默认情况下，注视已合并集合中的任一成员都会同时高亮所有成员。若要改为只高亮玩家正在注视的那个具体对象——同时整个集合仍会作为一个逻辑对象进入 AI 的注意——请勾选 **注视时仅高亮此对象** (`bHighlightOnlyThisWhenGazed`) 在以下位置 **Convai | 对象 | 凝视** 在该成员上设置。此设置只会改变视觉高亮；它纯属外观效果，对未合并对象没有影响。

### 验证合并

进入播放模式并打开 [Convai 调试覆盖层](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/troubleshooting/convai-debug-overlay.md) 使用 **Ctrl+Alt+K**。选择聊天机器人并检查 **周围环境** 面板：已合并集合应以共享名称显示为一行，而不是每个板条箱一行。其位置应读取自堆中大致位于中间的一个点。

### 下一步

{% content-ref url="/pages/7e106191f2eaa9dd6a1b3cfbbbf3a7e6e171e3bf" %}
[空间感知的工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/spatial-awareness/how-spatial-awareness-works.md)
{% endcontent-ref %}

{% content-ref url="/pages/61357e0f0cdf694475bb5b1ab006fa4ae40d02e2" %}
[空间感知设置参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/spatial-awareness/spatial-awareness-reference.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-unreal-engine-plugin/features/spatial-awareness/merge-same-named-objects.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.
