Menu
Lumberyard
User Guide (Version 1.13)

Audio PlayTriggers and StopTriggers

This topic references tools and features that are legacy. If you want to use legacy tools in Lumberyard Editor, disable the CryEntity Removal gem using the Project Configurator or the command line. To learn more about legacy features, see the Amazon Lumberyard Legacy Reference.

You can define both a PlayTriggerName and StopTriggerName for audio entities in your level.

To access these properties, select the audio entity, and then view the Properties panel for the entity on the Rollup Bar.

Placing Triggers in Game

To hear a sound in the game, first place the audio entity that executes the audio trigger during gameplay. For each level, we recommended creating a dedicated audio layer that contains all your audio data. In the Rollup Bar, on the Layer tab, click the New layer icon, and then name the layer. Select the audio layer to ensure that all entities that you are placing in the level are included in this layer.

On the Objects tab in the Rollup Bar, click Audio, AudioTriggerSpot, and then drag and click to place the entity in the level.

PlayTriggerName

Upon activation of the audio trigger, the event specified in PlayTriggerName is executed. When that audio trigger is deactivated, the PlayTriggerName event is killed. Furthermore, if a StopTriggerName is specified, then the StopTriggerName event is executed when the audio trigger is deactivated.

This automatic stopping of the event can be useful, as you do not need to create any additional stop functionality inside of your audio middleware. It also assures that any looping sounds are stopped when the associated entity is disabled.

StopTriggerName

Upon deactivation of the audio trigger, the event specified in StopTriggerName is executed. For example, this can be playing another sound, or stopping all sounds, and so on.

You can bypass the automatic stopping of the StartTriggerName event by setting the do_nothing ATL control as the StopTriggerName. This can be useful, for example, when setting an audio trigger on a shooting animation of a gun, as you would want to hear the end of the gunfire even after the animation has finished. However, if you have not set an event in the StopTriggerName field, the PlayTriggerName would be terminated and cut short the gunfire sound. Setting do_nothing in StopTriggerName allows the PlayTriggerName to play in its entirety.

Note

If you set a looping sound as your PlayTriggerName, and then set do_nothing as your StopTriggerName, the looping sound will continue to play until stopped by some other method.

If you need to stop the PlayTriggerName with another audio trigger that is set as StopTriggerName, then you need to set up stop functionality inside of your audio middleware.

As a general rule, it is always useful to use the automatic stop behavior contained in the audio system when you just want to simply stop a sound on entity deactivation or on the ending of an animation. When creating more complex events, such as fade outs or triggering additional audio samples while stopping PlayTriggerName, create the stop functionality inside your audio middleware and set the connected ATLControl as the StopTriggerName.