> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/trigger-area.md).

# 触发区域

对玩家的位置做出反应

要让玩家走进或走出某个区域时触发某事，请使用触发区域 [智能物品](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items.md).

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-649dfd99d06849f543399b5b89a6a31a015cb439%2Ftrigger.png?alt=media\&token=cbc5fb9b-ecff-4733-b799-38b59244f78b)

你在编辑场景时看到的橙色立方体只会在场景编辑器中可见，在运行场景预览时它会变为不可见。你可以轻松调整并缩放橙色立方体，使其正好覆盖你需要的区域。

将它拖入你的场景，并使用缩放操纵器调整大小。你看到的方盒或球体只会在编辑器中绘制，玩家永远看不到它。

如果玩家头像的任何部分与这个橙色立方体重叠，就会调用分配的事件。触发区域只对本地机器上的玩家作出反应，不会对其他玩家的头像作出反应——每位玩家都会在自己那一份场景实例中触发该触发器。

{% hint style="info" %}
**💡 提示**：如果你场景中的触发区域开始妨碍编辑其他内容，记住你始终可以锁定和/或隐藏它们，从 [实体树](/creator/content-creator-zh/chang-jing-bian-ji-qi/ru-men/scene-editor-essentials.md#the-entity-tree).

<img src="https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-22638c584105c16e473cdbcab644d55b04540fc4%2Fhide-trigger.png?alt=media" alt="" data-size="original">
{% endhint %}

多个触发区域可以重叠，并且不会相互影响。

你描述应该发生什么，而 [AI 助手](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-yong-dai-ma-kuo-zhan/ai-assistant.md) 会为它编写一个小脚本。

### 设置

该物品的 **脚本** 组件有两个字段：

| 字段       | 作用         | 选项                                                         | 默认     |
| -------- | ---------- | ---------------------------------------------------------- | ------ |
| **激活方式** | 是什么触发该区域。  | `我的玩家`, `所有玩家`, `任何碰撞体`, `可点击项`, `自定义 1`, `自定义 2`, `自定义 3` | `我的玩家` |
| **形状**   | 体积是方盒还是球体。 | `盒体`, `球体`                                                 | `盒体`   |

`我的玩家` 只对正在运行场景的玩家头像作出反应。 `所有玩家` 对任何头像作出反应，包括场景中的其他人。其余选项与其他 [碰撞层](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/colliders.md)一致，因此你可以让区域对物理对象、可点击对象或你自己的自定义层作出反应。

切换 **形状** 在方盒和球体之间切换编辑器占位物，因此你在编辑时看到的就是你将获得的体积。

### 描述应该发生什么

该区域会触发两个事件： **进入** 和 **退出**。在 **反应** 部分中，Script 组件为每个事件都有一个按钮：

* **当玩家进入……**
* **当玩家离开……**

点击其中一个，Creator Hub 就会在 AI 助手的消息框中写入一个句子的开头，并命名该物品，例如 `当玩家进入“触发区域”时，` 。提示会使用你在实体树中看到的物品名称。用你希望发生的内容完成句子并发送。助手会编写一个单独的脚本，并将其附加到同一个实体上，与检测器并列。

按钮旁边的三个芯片（**播放声音**, **显示消息**, **获得分数**）会为你补全成一个完整句子，因此你可以直接发送。

{% hint style="info" %}
**💡 提示**：反应需要 [AI 助手](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-yong-dai-ma-kuo-zhan/ai-assistant.md) 已开启。如果未开启，Creator Hub 会告诉你该在哪里启用它，而不是打开聊天。
{% endhint %}


---

# 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.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/trigger-area.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.
