viverse logo

EntityEnableCollision

EntityEnableCollision - Create An Action That Enables An Object's Collider

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

1 2 3
The avatar is able to pass through the wall when the wall’s collider is disabled. Once the avatar enters the red trigger area, the EntityEnableCollision action enables the wall’s collider The avatar is unable to pass through the wall once the wall’s collider is enabled.

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 enable 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 (0.5, 1, 0.5) for X, Y, Z.

D. Click the "EDIT VIVERSE EXTENSION" button to add the VIVERSE functionality.

4

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 EnableWall name is added. All of the objects that subscribe to the EnableWall notification will receive notification.

5

3. In this example, the object receiving the notification to enable 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 (.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.

6

4. To add the EntityEnableCollision 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 EnableWall name is added. This object will receive notifications from objects that publish to the EnableWall notification name.

F. Click "+" beside the selected module dropdown.

G. Click the type dropdown and select the EntityEnableCollision action.

7

Previous

EntityToggleCollision

Next

EntityDisableCollision