viverse logo

EntityStopSound

EntityStopSound - Create An Action That Stops Playing A Sound

This guide provides instructions for setting up the EntityStopSound action. In the sample app, once the avatar leaves the trigger area, the sound stops playing.

1 2
The avatar is outside of the blue trigger area and the sound does not play. The avatar enters the blue trigger area and the sound plays.

1. In this example, a trigger is created and when triggered, an action plays a sound. 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. Click the "Add Component" button again and select Audio > Sound to add a Sound 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. On the Sound component, add a name in the Name field. In this example, the name has been changed to Slot1. Add a sound file to the asset field. Place a checkmark by the Loop property to make the sound play continuously.

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

3

2. To add the EntityStopSound 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 EntityStopSound action in the dropdown menu. For the EntityStopSound action to work, the name of the first sound slot need to be added to the sound name to play field. In this example, Slot1 is added to the field. The entity with the sound component needs to be added to the pick up specify execution entity. The sound component was added to the TriggerArea entity, so that is the entity that is added to the field.

4

 

 

Previous

EntityPlaySound

Next

EntityToggleEnabled