Skip to content

Setting Switches

Alessandro Famà edited this page Dec 13, 2023 · 2 revisions

Switches are a type of Game Sync that enable the implementation of variations for specific sound objects. They are commonly used for features like multi-surface footstep sounds, where different sets of sounds are played based on the surface the player is walking on. Unlike States, Switches are applied at the local game object level, meaning they can be unique for each instance of a game object.

Setting Switches with the AkSwitch Node

The integration provides a custom node called AkSwitch, which allows you to set switches easily:



wwise-godot-ak-switch-inspector

The AkSwitch node has the following properties:

  • AkEvent: Specifies the path to the AkEvent (and the corresponding game object) on which the switch should be set.
  • Switch Group: Selects the desired switch group.
  • Switch Value: Sets the desired switch value within the selected switch group.
  • Trigger On: Specifies when the switch should be set (e.g., Enter Tree, Ready, Exit Tree).

To use the AkSwitch node, select the event from the scene tree and fill out the other properties accordingly.

Triggering a AkSwitch node with GDScript

If you left the Trigger On property of an AkSwitch node to None, you can trigger setting the switch by referencing the node and calling set_switch:

func _ready():
	$AkSwitch.set_switch()

Setting Switches with GDScript

To set a switch using GDScript, you can utilize the set_switch or set_switch_id functions provided by the Wwise singleton:

Using switch names:

func _enter_tree():
	Wwise.set_switch("Footsteps", "Water", game_object)

Using switch IDs:

func _enter_tree():
	Wwise.set_switch_id(AK.SWITCHES.FOOTSTEPSSWITCH.GROUP, AK.SWITCHES.FOOTSTEPSSWITCH.SWITCH.WATER, game_object)

The set_switch functions take the switch group and switch value as names or IDs, along with the game object on which the switch should be set. If you have generated the Wwise IDs, you can access them by referencing the AK class.