版本

menu_open

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.gif
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 developers call triggers using the SDK AK::SoundEngine::PostTrigger() command, the triggers may become difficult to control. We strongly recommend that sound designers and audio developers 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:

AK::SoundEngine::PostTrigger(
    L"TriggerName",
    myGameObject1
);

or

AK::SoundEngine::PostTrigger(
    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:

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅