> 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)

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

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

使用 **玩家进入区域** 和 **玩家离开区域** 物品上的触发类型 **触发器** 组件中。这些触发事件上的动作会在玩家每次进入或离开该区域时被激活。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-f8389cd077c495e0b8ada33ca0da01800eee7dcd%2Fon_player_enters.png?alt=media)

你可以在同一个触发事件上添加任意多个不同的动作，这样它们就会同时被激活。

{% hint style="info" %}
**💡 提示**：如果你场景中的触发区域开始妨碍你编辑其他内容，记住你始终可以从 [实体树](/creator/content-creator-zh/chang-jing-bian-ji-qi/kai-shi-shi-yong/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 %}

你也可以添加 **触发条件**，这样只有在场景中满足某些条件时才会执行这些动作。例如，你可以设置一个触发区域，在玩家走进时打开一扇滑动门；你可以在这里使用一个条件来检查作为电源开关的拉杆状态，并且只有在电源开启时才打开门。参见 [状态和条件](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/states-and-conditions.md) 了解更多详情。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-7b4672a813859334f5951ee8c1e2d31a90509d32%2Ftrigger-conditions-trigger-area.png?alt=media)

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

{% hint style="info" %}
**📔 注意**：你也可以使用 **当玩家进入区域时** 和 **当玩家离开区域时** 在任何其他智能物品上设置触发事件，但请注意，要判断触发器覆盖的区域可能会有些困难。

可触发区域的大小与物品的可见形状或其碰撞体无关，它始终是一个每边 1 米的立方体，并会受物品缩放的影响。
{% endhint %}

{% hint style="info" %}
**💡 提示**：场景编辑器中的触发区域只会对本地玩家触发。如果你还需要对其他玩家的头像进入该区域作出反应，请使用 Script 组件添加代码，并使用 [SDK7 TriggerArea 组件](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/trigger-areas.md) 配合 `CL_PLAYER` 碰撞层，它可以检测所有头像。
{% 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 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.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/trigger-area.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.
