版本
menu

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.

使用 AK::SoundEngine::PostTrigger() 调用触发器

有两种方法可从 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 中调用触发器的方式如下:

L"TriggerName",
myGameObject1
);

或者

AK::TRIGGERS::TRIGGER_NAME,
myGameObject1
);

启用 ID

要使用 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.

参见
AKSOUNDENGINE_API AKRESULT PostTrigger(AkTriggerID in_triggerID, AkGameObjectID in_gameObjectID)

此页面对您是否有帮助?

需要技术支持?

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

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

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

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

开始 Wwise 之旅