Table des matières
Once the game regions or areas have been defined in a scene, you can use a Trigger to encapsulate the space and detect when other Triggers are entering. In the Wwise Adventure Game and in this certification, we'll be referring to this trigger and its components as an Aux Environment (not to be confused with Audio Environments, which in the Wwise Adventure Game refers to the region-exclusive Scenes).
To create an Aux Environment, you can use the premade AkEnvironment script, included in the Wwise Unity Integration. When this script is added to a Trigger, all game objects with the AkGameObj component set to Environment Aware will be assigned the aux bus when inside the Trigger.
Crucially, Wwise will also need to know which sounds are going to have their Auxiliary sends controlled from the game, and so the corresponding Audio objects should have the Use game-defined auxiliary sends toggle enabled.
The AkAmbient will only affect game objects with an AkGameObj component, set to environment-aware, to keep track of environment related properties such as send values. Learn more about environment-aware objects in the section - Creating an Aux Environment.
In the following steps, you will create an Aux Environment in the starting area (also referred to as Training Area) and ensure that the correct aux bus is assigned using the Profiler. All sounds set to environment-aware and Use game-defined auxiliary sends will then send to the aux bus selected for that area.
In the Unity menu, go to Audiokinetic > Certifications > 301 > Lesson 6 and select Adding the AkEnvironment to a Trigger.
In the Hierarchy, expand the AUX Environment game object and select the Training game object.
The Training game object will have a Mesh Trigger attached. For the sake of demonstration, we've enabled a semi-transparent Mesh Renderer that will allow you to see the sides of the shape. All that remains to be fixed with this Trigger is to add the AkEnvironment script and assign it to the correct aux bus.
In the Inspector, click Add Component, then type in AkEnvironment and select it.
In the Inspector, you will see the AkEnvironment script and, above it, the Collider used.
Whenever any other game object with a collider enters this Mesh Collider, the AkEnvironment script will check if it's environment-aware. If so, the Wwise object will be assigned to the selected aux bus.
Click the AuxBus Name, expand Wwise 301 > Auxiliary Busses > Default Work Unit > Master Audio Bus > World > AUX > Region_Village and select the Training aux bus.
That's it! By simply attaching the script and setting the aux bus name, all environment-aware sounds within that region will receive the effects of that aux bus, as long as the 'Use game-defined auxiliary sends' is selected on the Wwise object. Next, let's connect the Profiler and verify the implementation on sounds within the Trigger.
In Wwise, go to the Profiler layout, and in the Advanced Profiler's Voices Graph, click the Filter browse (...) button.
Expand Master-Mixer Hierarchy > Default Work Unit > Master Audio Bus > World > AUX > Region_Village, then select the Training aux bus and click OK.
The Profiler is ready, so let's connect to the game. To get a better overview while playing, it's advised to set up Wwise and Unity next to each other, or on two separate screens, so you can watch both the Advanced Profiler and the Game view simultaneously.
Remote Connect to the Wwise Adventure Game (editor), and Play the Scene in Unity.
In the Training area, run to a stone and attack it.
When attacking, look in the Advanced Profiler > Voices Graph. All Wwise objects triggered from the Player_WeaponSwing Event are now routed through the Training aux bus and receiving a Wwise RoomVerb Effect.
Let's compare the result to an area with no Aux Environment. The AkEnvironment component on the Village Trigger has been removed, so to try the sound without any Effects applied, you can run to the Village and hit a stone.
Run to the Village, find a stone and attack it.
With the sound of the weapon without any aux sends, you are ready to set up your own region-based effects.
By adding the AkAmbient script to the premade Training Trigger, you have now built an Aux Environment in the Training Area. In the following section, you will learn how to create an Aux Environment from scratch.