# Event Listeners

***

### EntitySubscribeTriggerEnter

This guide provides instructions for setting up the **EntitySubscribeTriggerEnter** trigger. In the sample app below, the trigger areas are outlined in blue. Once the avatar enters into the blue area, an action occurs.

| <img src="/files/woPFo38JprYg1l0CbgA5" alt="" data-size="original">           | <img src="/files/lhdQRy7iFkHB0iWy6z5Z" alt="" data-size="original">        |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| The avatar is outside the blue trigger area and the gold coin is not visible. | The avatar has entered the blue trigger area and the gold coin is visible. |

In our example above, a trigger area is created. When the avatar enters the trigger area, an action is then initiated. Any object can be used as a trigger, as long as the object has a collision component. Our example uses a 3D box as the trigger area.

#### **Create a trigger for when an object enters an area**

{% stepper %}
{% step %}
**Create a trigger area**

A. Create a new **3D Box** entity.

B. Add a **Collision** component.

C. Adding a material is optional. A transparent material has been added so that the trigger area is visible in play mode.

D. Click the **Edit Viverse Extension** button.

<figure><img src="/files/OUYMJyKLnggmwt38xKhS" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *EntitySubscribeTriggerEnter* **trigger**

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **EntitySubscribeTriggerEnter**.

C. Add **local-player** to the **tags to filter** field.

D. Add an **Action** and select **EntityEnableById.**

E. Add an object that will be enabled when the avatar enters the trigger area. The **golden\_coin** entity has been added to the **pick up specify execution entity**. The **golden\_coin** entity has also been disabled by default.

<figure><img src="/files/DWOpPIJcWLxdjJDzbOor" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### EntitySubscribeTriggerLeave

This guide provides instructions for setting up the **EntitySubscribeTriggerLeave** trigger. In the sample app, the trigger areas are outlined in blue. Once the avatar leaves the blue area, an action occurs.

| <img src="/files/Fg2yOBaaKQTAxLDUBN6m" alt="" data-size="original">          | <img src="/files/sUIkrN8JR6aDeEjqHsMp" alt="" data-size="original">             |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| The avatar is inside the the blue trigger area and the gold coin is visible. | The avatar leaves the blue trigger area and the gold coin is no longer visible. |

In this example, a trigger area is created and when the avatar leaves the trigger area, an action is initiated. Any object can be used as a trigger, as long as the object has a collision component. This example uses a 3D box as the trigger area.

#### **Create a trigger for when an object leaves an area**

{% stepper %}
{% step %}
**Create a trigger area**

A. Create a new **3D Box** entity.

B. Add a **Collision** component.

C. Adding a material is optional. A transparent material has been added so that the trigger area is visible in play mode.

D. Adding a material is optional. A transparent material has been added so that the trigger area is visible in play mode.

<figure><img src="/files/9pk16qv4aMjjlrzik6ig" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *EntitySubscribeTriggerLeave* **trigger**

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **EntitySubscribeTriggerLeave**.

C. Add **local-player** to the **tags to filter** field.

D. Add an **Action** and select **EntityDisableById.**

E. Add an object that will be disabled when the avatar leaves the trigger area. The **golden\_coin** entity has been added to the **pick up specify execution entity**.

<figure><img src="/files/nYxmvYIAj73PZT7op6lU" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### EntitySubscribeCollisionStart

This guide provides instructions for setting up the **EntitySubscribeCollisionStart** trigger. In the sample app, the **golden\_coin** is a trigger. Once the avatar collides with the **golden\_coin**, an action occurs.

| <img src="/files/lydwYkURBnCSwvGcQy3f" alt="" data-size="original"> | <img src="/files/cprMzrWyERZPDeOlNCM5" alt="" data-size="original">    |
| ------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| The avatar approaches the gold coin.                                | Once the avatar collides with the gold coin, the gold coin is removed. |

In this example, a trigger is created and when the avatar collides with the trigger, an action is initiated. Any object can be used as a trigger, as long as the object has a collision component. Because this specific example uses a 3D object that the avatar can collide with, a **RigidBody** component needs to be added. In this example, the object **golden\_coin** is used, but a simple cube will suffice.

#### **Create a trigger for when an object collides with another object**

{% stepper %}
{% step %}
**Create the 3D object that the avatar will collide with**

A. Add 3D object to the scene.

B. Add a **Collision** component.

C. Add a **Rigidbody** component.

D. Click the **Edit Viverse Extension** button.

<figure><img src="/files/mzZd0iLF4t0i5vqMgr7F" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *EntitySubscribeCollisionStart* **trigger**

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **EntitySubscribeCollisionStart**.

C. Add **local-player** to the **tags to filter** field.

D. Add an **Action** and select **EntityDisable.**

<figure><img src="/files/lV2QefBQ0C8FhgDcifvO" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### EntitySubscribeCollisionEnd&#x20;

This guide provides instructions for setting up the **EntitySubscribeCollisionEnd** trigger. In the sample app, a flattened 3D cube is a trigger. Once the avatar stops colliding with the cube, an action occurs.

| <img src="/files/Nwc81bsiwPdRozrBjpwB" alt="" data-size="original"> | <img src="/files/McMOaCYyZHml72Lbe0mD" alt="" data-size="original">                         |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| The avatar is colliding with the red platform.                      | Once the avatar stops colliding with the red platform, the red platform begins to fade out. |

In this example, a trigger is created and when the avatar or other objects collide with the trigger, an action is initiated. Any object can be used as a trigger, as long as the object has a collision component. Because this specific example uses a 3D object that the avatar can collide with, a **RigidBody** component needs to be added.

#### **Create A Trigger Based On When An Object Stops Colliding With Another Object**

{% stepper %}
{% step %}
**Create the 3D object that the avatar will collide with**

A. Add 3D object to the scene.

B. Add a **Collision** component.

C. Add a **Rigidbody** component.

D. Click the **Edit Viverse Extension** button.

<figure><img src="/files/iTJb6j7UzNmiRCyJlkNU" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *EntitySubscribeCollisionEnd* **trigger**

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **EntitySubscribeCollisionEnd**.

C. Add **local-player** to the **tags to filter** field.

D. Add an **Action** and select **EntityFadeOut.**

<figure><img src="/files/j8xmfHCfJXdlf6AaC7Wd" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### NotificationCenterSubscribeEntityPicking

This guide provides instructions for setting up the **NotificationCenterSubscribeEntityPicking** trigger. In the sample app, the user clicks on the buttons to show and hide the whale.

| <img src="/files/a1n5PVakbU2jRnHbuyMg" alt="" data-size="original"> | <img src="/files/y6xox1c30IbQbH8Ld4ED" alt="" data-size="original"> |
| ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| The whale is visible.                                               | When the user clicks on the whale, the whale is disabled.           |

In this example, a trigger area is created on a button. When the user clicks on the trigger area, an action causes the 3D model to be disabled. Any object can be used as a trigger, as long as the object has a collision component.

#### **Create a trigger for when a user clicks an object**

{% stepper %}
{% step %}
**Create the 3D object that the user will click on**

A. Add a 3D object to the scene. In this example, a button is used, but any 3D object will work.

B. Add a **Collision** component.

C. Click the **Edit Viverse Extension** button.

<figure><img src="/files/ejQQTq8AttQ6w9LfEUwf" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *NotificationCenterSubscribeEntityPicking* **trigger**&#x20;

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **NotificationCenterSubscribeEntityPicking**.

C. Add an **Action** and select **EntityDisable.** Add an object that will be disabled.

<figure><img src="/files/JgQmdmIx69XPT91EvUjb" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### NotificationCenterPublish & NotificationCenterSubscribe

This guide provides instructions for setting up the **NotificationCenterPublish** action and the **NotificationCenterSubscribe** trigger. In the sample app, every time the avatar enters the green trigger area, a notification is sent to the wall and the collider on the wall is toggled on/off. The wall is green when the avatar can pass through and red when the avatar can not pass through.

| <img src="/files/w3AlbwhZj4hbgcZgeiGJ" alt="" data-size="original">                                            | <img src="/files/Kk8gOcix0pXcCkU9MpEq" alt="" data-size="original">                                                                         |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Before the avatar enters the green trigger area, the wall is red and the avatar can not pass through the wall. | Once the avatar enters the green trigger area, the green trigger sends a notification to the wall and the collider on the wall is disabled. |

In this example, a trigger is created and when the avatar enters the trigger area, an action sends a notification to another object. The other object receives the notification via trigger, then initiates an action.&#x20;

#### **Action and Trigger combination to send a notification from one object to another**

{% stepper %}
{% step %}
**Create the 3D object that will send the notification**

A. Add a 3D object to the scene.

B. The **Collision** component is not required for **NotificationCenterPublish** action or **NotificationCenterSubscribe** trigger to work. The **Collision** component is required for the **EntitySubscribeTriggerEnter** trigger that will be used in this example.

C. Click the **Edit Viverse Extension** button.

<figure><img src="/files/CczDGWyMtazqlTSVWoTM" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *NotificationCenterPublish* **action**

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **EntitySubscribeTriggerEnter**.

C. Add **local-player** to the **tags to filter** field.

D. Add an **Action** and select **NotificationCenterPublish.**

E. Create a unique notification name and add it to the **notification name to publish** field. In this example, the notification is called **ToggleWall**.

<figure><img src="/files/54U8Kr6kobwfgIq7hKoM" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Create the 3D object that will receive the notification**

A. Add a 3D object to the scene.

B. The **Collision** component is not required for **NotificationCenterPublish** action or **NotificationCenterSubscribe** trigger to work. The **Collision** component is required for the **EntityToggleCollision** action that will be used in this example.

C. The **Rigidbody** component is not required for the **NotificationCenterPublish** action or **NotificationCenterSubscribe** trigger to work. The **Rigidbody** component is required for the **EntityToggleCollision** action that will be used in this example.

D. Click the **Edit Viverse Extension** button.

<figure><img src="/files/dNgqtcZbjC4BFovDofD3" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Add the** *NotificationCenterSubscribe* **action**

A. In the VIVERSE extension, select the **TriggerAndAction** plugin for the **Select plugins** dropdown.

B. Add a **Trigger** and select **NotificationCenterSubscribe**.

C. The same text that was added to the **notification name to publish** needs to be added to the **notification name to subscribe**.

D. Add an **Action** and select **EntityToggleCollision.**

<figure><img src="/files/qvKOGYMjK01sHqSqwcRu" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}


---

# Agent Instructions: 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:

```
GET https://docs.viverse.com/playcanvas-toolkit/building-with-the-playcanvas-toolkit/no-code-tools/trigger-and-action/event-listeners.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
