Wwise SDK 2023.1.9
|
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 their 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.
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 they fight their 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.
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. |
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:
or
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.
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise