EntitySubscribeTriggerEnter - Create A Trigger Based On When An Object Enters An Area
This guide provides instructions for setting up the EntitySubscribeTriggerEnter trigger. In the sample app, the trigger areas are outlined in blue. Once the avatar enters into the blue area, an action occurs.
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. |
1. In this example, a trigger area is created and when the avatar or other objects enter the area, 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 creates an empty area that the avatar and other objects can pass through, a simple entity with a box shape is used instead of a 3D object. The entity does not have a RigidBody component added. Right-click in the Hierarchy and select New Entity > Entity.
A. Click the "Add Component" button. Select Physics > Collision to add a Collision component.
B. Resize the collider to the desired size. In this example, the Half Extents field has been set to (2.5, .5, 2.5) for X, Y, Z.
C. The entity itself is currently set to Position (0, 0, 0) for X, Y, Z. In this example, the values for Position Offset are set to (0, -2, 0) for X, Y, Z to lower the collider to the ground.
D. Click the "EDIT VIVERSE EXTENSION" button to add the VIVERSE functionality.
2. To add the EntitySubscribeTriggerEnter trigger functionality
A. Click the Select plugins text field and select TriggerAndAction in the dropdown menu.
B. Click "+" beside the Select a module and add dropdown.
C. Click "+" beside the selected module dropdown.
D. Click the type dropdown and select the EntitySubscribeTriggerEnter option in the dropdown menu.
E. Click "+" beside the selected module dropdown.
F. Click the type dropdown and select a desired action. In this example, the EntityEnableById action is selected. For the EntityEnableById action to work, an object needs to be added that will be enabled. In this example, the golden_coin object is added.