Table of Contents
To post a Wwise Event in Unity, Wwise needs to know two pieces of information:
The referenced game object.
The Trigger mechanism.
Unless specified otherwise, the Event will refer to the game object you attach the AkEvent script to. That game object will be used as a reference to calculate distance attenuation, Game Parameter values, Switches, and so on. In the AkEvent component, you will find a Trigger On property where you can select various Trigger methods.
We will add the 301_Campfire game object, post the Ambient_Campfire_Play Event when attached to it, and try to understand how it's placed in a 3D space.
In the Wwise Adventure Game, the listener is attached to the Main Camera and not the Player, and so any sound will calculate distance based on distance to the Main Camera.
In the Unity menu, select Audiokinetic > Certification > 301 > Lesson 1 > Playing your first Wwise Event.
First, you will find the 301_Campfire Prefab and drag it into as a new game object.
In the Project view, search for 'Campfire'.
This is simply one of many Prefabs and game objects you can select in the Wwise Adventure Game.
If you are not seeing a list in the Project view, you can change to it by dragging the bottom right slider all the way to the left.
Drag the 301_Campfire Prefab into the Scene View.
Use the Move tool (click 'W') to place it on the ground in the Training Area.
As you have now added a game object to the scene, you can post an Event attached to it. As previously mentioned, a convenient way to add an Event to a game object is to use the Wwise Picker.
In the Wwise Picker, open Events > Ambient > General and select the Ambient_Campfire_Play.
From the Wwise Picker, drag the Ambient_Campfire_Play Event onto the 301_Campfire game object in the Hierarchy.
And done! By dragging the Ambient_Campfire_Play onto the 301_Campfire game object, we automatically set the Event to Ambient_Campfire_Play and added the necessary scripts to play the Event (AkAmbient and AkGameObj). When the game starts, the sound will be loaded from the General SoundBank then posted with reference to the Campfire game object. Should you choose to move the game object at runtime, the sound will follow the game object's position. To verify your integration of the Ambient_Campfire_Play, you should enter Play mode and listen for it. But before this, you should change layouts so you will be able to see the Scene and Game view simultaneously.
In the Unity menu, click Window > Layouts and select 2 by 3.
Use the mouse to rotate the Camera while looking at the 301_Campfire game object.
Depending on where the camera is located relative to the 301_Campfire game object, the sound's orientation in the soundscape will change. The AkAudioListener component (the Listener), is attached to the Main Camera, but the sound emits from the center of the game object. Their relative distance and angle, therefore, impact the audibility.
Press P (to show the mouse) and, in the Hierarchy, select the 301_Campfire game object.
You can also select the 301_Campfire game object in the Scene view; but, if you do, make sure that you have not selected any of the 301_Campfire game object children instead of the top one with the sound posted on it.
Use the Move tool ('W') to move the Campfire game object away from the Main Camera.
As the Ambient_Fire_Campfire Sound SFX is using 3D spatialization, and the Ambient_Campfire_play event is posted on the 301_Campfire game object, the game will continually update the sound's position to where you move the game object. Lastly, let's reset the layout to default for the upcoming exercises.
In the Unity menu, click Window > Layouts and choose Default.
Using the Wwise Unity Integration scripts, you can quickly get any Event from Wwise into the game, as long as you have loaded the SoundBank (including that Event) beforehand.