EntityToggleEnabled - Create An Action That Toggles An Object's Enabled State
This guide provides instructions for setting up the EntityToggleEnabled action. In the sample app, every time the avatar enters the blue trigger area, a notification is sent to the purple box to toggle it’s enabled state.
The purple box is enabled/visible before the avatar enters the blue trigger area. | Once the avatar enters the blue trigger area, a notification is sent to the purple box to toggle it’s enabled stated. The purple box is disabled. | The avatar leaves the blue trigger area. | Once the avatar enters the blue trigger area, a notification is sent to the purple box to toggle it’s enabled stated. The purple box is enabled again. |
1. In this example, a trigger is created and when the avatar or other objects enter the trigger area, an action sends a notification to toggle another object's enabled state. 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 3D box is used. The entity does not have a RigidBody component added. Right-click in the Hierarchy and select New Entity > 3D > Box.
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. Click the "EDIT VIVERSE EXTENSION" button to add the VIVERSE functionality.
2. To add the NotificationCenterPublish action 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 a desired trigger. In this example, the EntitySubscribeTriggerEnter trigger is selected.
E. Click "+" beside the selected module dropdown.
F. Click the type dropdown and select NotificationCenterPublish action in the dropdown menu.
G. Add a name for this notification in the notification name to publish field. In this example, the Toggle name is added. All of the objects that subscribe to the Toggle notification will receive notification.
3. In this example, the object receiving the notification is a simple 3D cube. Any object can be used to receive notifications. Right-click in the Hierarchy and select New Entity > 3D > Box.
A. Click the "EDIT VIVERSE EXTENSION" button to add the VIVERSE functionality.
4. To add the EntityToggleEnabled action 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 a trigger. In this example, the NotificationCenterSubscribe trigger selected.
E. In the notification name to subscribe field, add the same name that was used in the NotificationCenterPublish action. In this example, the Toggle name is added. This object will receive notifications from objects that publish to the Toggle notification name.
F. Click "+" beside the selected module dropdown.
G. Click the type dropdown and select a desired action. In this example, the EntityToggleEnabled action is selected.