EntityDisableCollision - Create An Action That Disables An Object's Collider
This guide provides instructions for setting up the EntityDisableCollision action. In the sample app, every time the avatar enters the green trigger area, a notification is sent to the wall object and the collider on the wall object is disabled. The wall is green when the avatar can pass through and red when the avatar can not pass through.
The avatar is unable to pass through the wall when the wall’s collider is enabled. | Once the avatar enters the green trigger area, the action disables the wall’s collider | The avatar is able to pass through the wall when the wall’s collider is disabled. |
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 disable another object's collider. 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. In this example, the cube has been enlarged by setting the values for Scale to (1, 2, 1) for X, Y, Z.
B. Click the "Add Component" button. Select Physics > Collision to add a Collision component.
C. Resize the collider to the desired size. In this example, the Half Extents field has been set to (.5, 1, .5) for X, Y, Z.
D. 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 DisableWall name is added. All of the objects that subscribe to the DisableWall notification will receive notification.
3. In this example, the object receiving the notification to disable it's collider is a simple 3D cube that is used as a wall to prevent the avatar from moving forward. Any object can be used to receive notifications. Because the avatar will be colliding with this object, Collision and RigidBody components are added. Right-click in the Hierarchy and select New Entity > 3D > Box.
A. In this example, the cube has been enlarged by setting the values for Scale to (0.25, 1.75, 4.58) for X, Y, Z.
B. Click the "Add Component" button. Select Physics > Collision to add a Collision component. Click the "Add Component" button again and select Physics > Rigid Body to add the RigidBody component.
C. Resize the collider to the desired size. In this example, the Half Extents field has been set to (0.15, 1, 2.3) for X, Y, Z.
D. Click the "EDIT VIVERSE EXTENSION" button to add the VIVERSE functionality.
4. To add the EntityDisableCollision 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 trigger. In this example, the DisableWall name is added. This object will receive notifications from objects that publish to the DisableWall notification name.
F. Click "+" beside the selected module dropdown.
G. Click the type dropdown and select the EntityDisableCollision action.