|
Wwise SDK 2024.1.9
|
Swtich(切换开关)是在游戏动作或环境变化时提供全新声音的变换。切换开关系统有一个目的:以游戏对象为基础驱动 Switch Container(切换容器)。
For example, if ground texture is set as a switch, the ground texture decides which sound will be played when a footstep occurs:
Switch Group(切换开关组)可以是:
此组的切换开关可以是:
At a given time, if two different characters are on two different ground textures, the switch-states of each character will be different.
If there is no current switch for a switch group, the switch group uses the default switch. 这种情况可能发生在游戏开始或开发期间。A switch container will also use the default switch if the game code refers to a switch that does not exist. For example, if the sound designer changes a container to remove a switch, but does not inform the audio programmer, that switch remains in the code. When that code is executed in the game, the switch to which it refers no longer exists, so the default switch is used.
You have three options to drive switches: the SDK AK::SoundEngine::SetSwitch() method, the "SetSwitch" action generated in Wwise events, or RTPCs. However, combining these options can be problematic. For example, if sound designers introduce SetSwitch actions inside the events they create while audio programmers drive switches using the SDK AK::SoundEngine::SetSwitch() command, the switches may become difficult to control. We strongly recommend that sound designers and audio programmers decide how the actual switches will be driven, either for each switch group or for the entire project. All three ways can be used together, if there is agreement on how switches will change. For example, the audio programmers can initialize switches using the SDK AK::SoundEngine::SetSwitch() command, but leave the switch to be driven by events for the rest of the game.
有两种方式可使用 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. Using IDs avoids string look-up time and saves memory that would be used for storing string mapping.
使用 SDK 设置切换开关无非就是调用函数:
或者
The third parameter of the SetSwitch() function is the game object to which the switch should be applied. When an event containing a play action is triggered using this game object, it will use the specified switch to select what to play in the switch container. If a switch has not been set for a game object, the object will use the default switch specified in the switch container options.
注意,当游戏对象被注销时,它当前的切换开关也会被删除。If the game object is used again later, this switch will have to be reset.
有关更多信息,请参阅 集成详情——游戏对象 。
要使用 ID,必须在选中 Wwise 中 Generate SoundBanks 对话框上的“Generate header file”选项的情况下生成 SoundBank。名为 Wwise_IDs.h 的定义文件中包含所有必要的 ID。每次生成 SoundBank 时都会更新此文件。
The main difference between a state group and a switch group is that the switch will be different for every game object in the game. Another difference between states and switches is that when a switch changes, only switch containers will be affected. When a state changes, it may affect switch containers but may also change the parameters of various other objects (sounds, actor-mixers, busses, and so on).
![]() | 技巧: 如果要在游戏中做全局的切换,并应用于所有游戏对象,则应使用状态(已经有全局性)而非为每个游戏对象设置切换开关。这将减少您的工作量,节省平台内存和运算时间。 |
有关集成切换开关的示例,请参阅 切换开关示例 。