Table of Contents
-
Lessons
For any game to enable sound, you need both an emitter and a listener. The emitter is the AkGameObj component handling the posted Events on the game object, whereas the listener refers to the game object with the AkAudioListener component. In the Wwise Adventure Game, the AkAudioListener component is attached to an Ak Listener Distance Probe object on the Player, so all attenuations and distances are based on the player position. The Main Camera defines the listener direction and therefore determines sound panning and so on.
In the above image, the emitter is the AkGameObj on the Ambient_River Event's game object. The listener is most often the character you are controlling, the camera through which you are viewing, or a combination that uses a third-person listener, as in the Wwise Adventure Game. In the UniqueName's Hierarchy, you will find a Main Camera, a Directional Light, and a WwiseGlobal game object.
By default, the AkAudioListener script will automatically be added to the Main Camera, but let's disable that option and add the AkAudioListener to a new separate Player game object.
-
In the Unity menu, select Edit > Project Settings.
-
In the Project Settings window, select Wwise Editor.
By default, the Wwise Unity Integration will add a listener to the Main Camera, as it is the most common use case. However, as some games require sounds to be based on where the Player is and not the Camera, like some 2D side-scrollers, let's manually add the listener to another game object.
-
Under Global Settings, make sure that Add Listener to Main Camera is cleared and close the window.
As the Untitled Scene was loaded once you opened Unity, the AkAudioListener will still be on the Main Camera even though the new scenes you'll make will not. As you have not changed anything in the Scene yet, a quick way to solve this is by creating a new Scene.
-
In the Unity menu, select File > New Scene.
-
In the New Scene dialog, select Basic (Built-in) and click Create.
-
In the Hierarchy, select the Main Camera.
In the Inspector you will now see three components, with one of them being an Audio Listener component provided by Unity. This component is used with the Unity Audio Engine; however, as you are using Wwise, you should remove this component.
-
Click the Component Context Menu (vertical dots) and select Remove Component.
Next, let's make a new game object, which we can use as the Player or character in the game, and add the AkAudioListener script to it. Ensure that you are viewing the Scene tab so you can see the new object appear in the Scene.
-
In the Hierarchy, right-click in an empty space, go to 3D Object, and select Capsule.
This capsule will act as the Player game object.
-
In the Inspector, click Add Component, search for AkAudioListener and select it.
You have now added the Wwise Unity Integration Listener to the Capsule game object.
When you added the AkAudioListener, the AkGameObj script was also added. The AkGameObj script is used by the AkAudioListener, and so it was added automatically.