Version

menu_open
Wwise SDK 2019.2.15
Integration Details - Triggers

Introduction

Like all game syncs, a trigger is a Wwise element that is first called by the game, then defines a specific response in Wwise to accommodate the game action that required it to be called. More specifically, in interactive music a trigger responds to a spontaneous occurrence in the game and launches a stinger. The stinger (a brief musical phrase) is mixed with the currently-playing music, as a musical reaction to an in-game event. For example, when a ninja draws his weapon, you might want to insert a musical sforzando-type progression over the music to add even more impact to the scene. The game would call the trigger which in turn would launch the stinger and your music clip would play over the ongoing score.

Example: Trigger

Let's say that you have created a stealth-based game in which your main character is a well-known spy figure. At several points in the game, your character goes into a mode in which he fights his enemies. When your character lands a powerful blow, you might want to place a music clip that will intensify the auditory impact of that scene.

To build your music for these sequences, you will need to create a trigger, perhaps named 'Headshot', to be called in such situations. In addition, you will need to define the short music segment that will provide the quick blast of brass emphasizing the game action.

For an example of how triggers are integrated, continue reading Trigger Example.

Calling Triggers

There are two options to call a trigger: the SDK's AK::SoundEngine::PostTrigger() method and the "Trigger" action generated in Wwise events.

Warning: Combining trigger calls through the SDK and through actions in events can be problematic. For example, if sound designers introduce trigger actions inside the events they create while audio programmers call triggers using the SDK AK::SoundEngine::PostTrigger() command, the triggers may become difficult to control. We strongly recommend that sound designers and audio programmers decide how triggers will be called in their project.

Calling Triggers with AK::SoundEngine::PostTrigger()

There are two ways to call a trigger from the SDK: using strings (Unicode and Ansi), or using IDs.

Using strings makes code more readable and is suitable during development time, or when working in an environment that normally uses strings. Using IDs avoids Wwise from having to hash the names at runtime.

Calling a trigger from the SDK is done as follows:

L"TriggerName",
myGameObject1
);

or

AK::TRIGGERS::TRIGGER_NAME,
myGameObject1
);

Enabling ID Usage

To work with IDs, the banks must be generated with the "Generate header file" option in the Generate SoundBanks dialog box in Wwise. The definition file, named Wwise_IDs.h, contains all the required IDs. It is updated at each bank generation.

The second parameter of the PostTrigger() function is the ID of the game object on which the trigger will be applied. Passing AK_INVALID_GAME_OBJECT as game object ID to AK::SoundEngine::PostTrigger() will force all registered game objects that define a behavior for the specified trigger to handle this trigger.

See also
AKSOUNDENGINE_API AKRESULT PostTrigger(AkTriggerID in_triggerID, AkGameObjectID in_gameObjectID)

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise