Skip to content

Tutorials

Alessandro edited this page Sep 18, 2020 · 21 revisions

Tutorials

Table of Contents


Loading Banks

Loading Banks by using the AkBank node

Create a new node and select the AkBank node from the node list:

In the inspector, select your desired bank and specify when the bank should be loaded or unloaded in Load On and Unload on:

Make sure to load the automatically exported Init bank before other banks in your project.

Loading Banks with GDScript

To load a bank with GDScript call load_bank or load_bank_id.

Note: The first string version will only work if you checked the Use SoundBank names in the SoundBanks project settings in the authoring app.

Example:

var result = Wwise.load_bank_id(AK.BANKS.INIT)
print(result)

Registering a Listener

Registering a Listener using the AkListener node

To register a listener, create a new node and select the AkListener from the node list:

That's it! The listener's position will be updated according to the node's position in the scene.

Registering a Listener with GDScript

To register a listener in code call register_listener. Make sure to update the listener position by calling set_3d_position.

Example:

Wwise.register_listener(self)
Wwise.set_3d_position(self, self.get_global_transform())

Posting your first Event

After loading the banks and registering a listener, is it time to play some sounds!

Posting an Event by using the AkEvent node

Create a new node and select the AkEvent node from the node list:

In the inspector of the AkEvent node you will find various fields:

If you have converted the Wwise IDs with the provided tool, you will be able to select your desired event from the Event drop down list. Select when the event should be posted in Trigger On.

Posting an Event with GDScript

To post an Event in code first register a GameObject by calling register_game_obj and then call post_event or post_event_id on the registered GameObject.

Example:

Wwise.register_game_obj(self, self.get_name())
Wwise.post_event_id(AK.EVENTS.MUSIC, self)

Using the Area and Body Entered/Exited Signals

Often we don't want to post an Event or to set a Switch as soon as the game starts. The integration makes use of the area_entered, area_exited, body_entered and body_exited signals to trigger an action on the custom Wwise nodes.

Let's have a look at this example scene:

We would like to post the Event as soon as it enters the Area on the right. At the same time we can stop the Event when it leaves the area. To achieve this behaviour we select Area Enter and Area Exit in the Trigger On and Stop On fields of the AkEvent node:

After that, select the Area on the right in the scene tree, switch to the signals tab and connect the area_entered signal to the AkEvent node:

Make sure to rename the receiver method to on_area_entered, since by default Godot inserts the node's name into the method's name. Repeat this step for the area_exited signal. Now by moving the AkEvent with the Area on the left side to the Area on the right side will trigger the Event, while moving the AkEvent back will stop the Event.

Note: every Area entering the Area on the right will trigger the Event. To properly filter out which exact Area node should post the Event, add a group tag to the AkEvent node:

and add the Area that is owned by the AkEvent node to a group with the same name.