|
Wwise SDK 2025.1.3
|
与所有游戏同步器一样,触发器一种 Wwise 元素,它首先由游戏调用,然后在 Wwise 中定义响应,以满足游戏动作的调用需求。具体地说,在互动音乐中,触发器为响应游戏中的突发事件而启动 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. 游戏调用触发器,触发器继而启动插播乐句,然后您的音乐片段将随当前配乐一起播放。
假设您在做一款潜行游戏,游戏的主人公是典型的间谍角色。在游戏中,主人公有时会进入与敌人格斗的模式。当主人公出绝招时,您可能希望播放一段音乐片段来强化当时场景的听觉冲击力。
要为这一系列动作创建音乐,您需要创建一个触发器,可能会取名为“Headshot”,以在这些情形下调用。另外,您还需要定义小音乐片段,以提供快速密集的铜管乐来强调游戏动作。
有关如何集成触发器的示例,继续阅读 触发器示例 。
有两个选项可用来调用触发器:SDK 的 AK::SoundEngine::PostTrigger() 方法和 Wwise 事件中生成的“Trigger”动作。
![]() | 警告: 组合使用 SDK 和事件动作来调用触发器可能会造成问题。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. |
有两种方法可从 SDK 中调用触发器:使用字符串(Unicode 和 Ansi),或者使用 ID。
Using strings makes code more readable and is suitable during development time, or when working in an environment that normally uses strings. 使用 ID 后,Wwise 就无需在运行时散列名称了。
从 SDK 中调用触发器的方式如下:
或者
要使用 ID,必须在选中 Wwise 中 Generate SoundBanks 对话框上的“Generate header file”选项的情况下生成 SoundBank。名为 Wwise_IDs.h 的定义文件中包含所有必要的 ID。每次生成 SoundBank 时都会更新此文件。
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.