> 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). Agents can also search and read this documentation through its [MCP server](https://docs.decentraland.org/~gitbook/mcp).

# 触发区域

对玩家的位置做出反应

要在玩家走进或离开某个区域时触发操作，请使用触发区域（Trigger Area） [智能物品](https://docs.decentraland.org/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-43dc86c2583a9d24ad70791dc7cdbdc7d4462d0c%2Ftrigger.webp?alt=media)

编辑场景时看到的橙色立方体只会显示在场景编辑器中；预览场景时它会变为不可见。你可以轻松调整橙色立方体的大小和比例，让它恰好覆盖所需区域。

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

只要玩家角色的任何部分与这个橙色立方体重叠，就会调用指定事件。触发区域只会响应本地机器上的玩家，不会响应其他玩家的角色——每位玩家都会在自己的场景实例中触发该区域。

{% hint style="info" %}
**💡 提示**：如果场景中的触发区域开始妨碍你编辑其他内容，请记住，你随时可以在 [实体树](https://docs.decentraland.org/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-904b0f80a11ab2704ee6162f9879b365f1dbc165%2Fhide-trigger.webp?alt=media" alt="" data-size="original">
{% endhint %}

中锁定和/或隐藏它们。多个触发区域可以重叠，且互不影响。

你只需描述想要实现的效果， [AI 助手](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-yong-dai-ma-kuo-zhan/ai-assistant.md) 就会为此编写一段小脚本。

### 设置

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

| 字段       | 功能         | 选项                                                                                          | 默认值         |
| -------- | ---------- | ------------------------------------------------------------------------------------------- | ----------- |
| **由谁触发** | 什么会触发该区域。  | `my player`, `all players`, `any collider`, `clickable`, `custom 1`, `custom 2`, `custom 3` | `my player` |
| **形状**   | 体积是盒体还是球体。 | `box`, `sphere`                                                                             | `box`       |

`my player` 仅响应运行场景的玩家角色。 `all players` 响应所有角色，包括场景中的其他玩家。其余选项对应其他 [碰撞层](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/colliders.md)，因此你可以让该区域响应物理对象、可点击对象或自定义层。

切换 **形状** 会在编辑器中将占位图形从盒体切换为球体，因此编辑时看到的形状就是实际使用的体积形状。

### 描述想要实现的效果

该区域会触发两个事件： **进入** 和 **离开**。在脚本组件的 **响应** 部分中，每个事件都有对应的按钮：

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

点击其中一个，Creator Hub 就会在 AI 助手的消息框中写入一句话的开头，并注明物品名称，例如 `当玩家进入“触发区域”时，` 。提示词使用实体树中显示的物品名称。接着补充你希望发生的情况，然后发送。助手会编写一个独立脚本，并将其附加到同一实体上，与检测器并列。

按钮旁的三个选项（**播放声音**, **显示消息**, **获得分数**）会为你补全整句话，因此你可以直接发送。

{% hint style="info" %}
**💡 提示**：必须启用 [AI 助手](https://docs.decentraland.org/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.
