Please be advised that the Audiokinetic offices will close at 3:00 p.m. EST on December 23rd, 2019 for the holiday period, and will reopen on January 3rd, 2020 at 9:00 a.m. EST. Learn more.

Lesson 2

Table of Contents

Using Multi Position Mode

A common approach to minimizing redundancy in Unity is to use modular objects like Prefabs to save many types of information in one piece. Take the Torch Prefab. It contains components that describe where it is, how it looks, and how it should behave. By adding an AkAmbient component to your Prefab, you ensure that the Torch sound will be included whenever someone adds a torch to the Scene. This is possible using either the AkEvent or AkAmbient script, but best suited for those purposes is the AkAmbient with a Position Type set to MultiPosition mode. While this mode is used to play an Event from the attached game object, just like the AkEvent or the AkAmbient's Simple mode, the MultiPosition mode allows you to only have one instance of the Event, no matter how many AkAmbient components that might have been added to the level.

In the following steps, you will add an AkAmbient component to the 301_Torch Prefab. You will start by having the AkAmbient set to Simple and then change it to MultiPosition Mode, to demonstrate the difference in voice instances.

  1. Make sure you are still in the AkAmbient Position Types Scene.

    To familiarize yourself with the Torch sounds, let's start by auditioning them in the dungeon. Meanwhile, connect the Profiler and take a look at the current amount of voice instances corresponding to the amount of Torches (17) in game.

  2. In Wwise's toolbar, click Remote…

  3. Select the Wwise Adventure Game (Editor) then click Connect.

  4. In Unity, click Play to enter Play mode.

  5. Press ESC to enter the game menu and teleport to the Dungeon.

  6. Run through the corridor and observe the sounds of the torches.

    Notice that the Torch sounds are all positioned directly at the Torch game objects, meaning that for each you pass by the sound will increase and decrease in volume.

  7. Press ESC to open the WAG menu and click Play again to exit Play mode.

  8. In Wwise, go to the Advanced Profiler's Voices Graph tab.

    Let's focus on only monitoring the Ambient_Torch Event by assigning it in the filter.

  9. Open the Filter browser, expand Events > Ambient > SoundBankSpecific > Dungeon > Ambient_Torch, and click OK.

    To get a simpler overview of the Ambient_Torch voice instances, you can deselect Game Object so the Events will be grouped.

  10. In the View: selector, deselect Game Objects.

  11. In the Performance Monitor, drag the time cursor backwards until you see the Ambient_Torch Event in the Voices Graph list.

    Notice that there are more than 10 voices using the Ambient_Torch Event. Let's now set the positioning type to MultiPosition mode and observe the change.

  12. In the Hierarchy, search for 'Torch' and select the 301_Torch_01 game object.

    A blue game object in the Hierarchy means the game object refers to a Prefab asset. Prefabs are templates of game objects. Dragging a Prefab in the Scene will create a game object identical to the Prefab. You can then modify that game object to suit your needs, but the original template will not be affected. However, there are ways to apply the changes you made on a game object back on the originating Prefab, so that every Torch will have have an AkAmbient set to MultiPosition mode.

    [Tip]

    To learn more about Prefabs you can visit https://docs.unity3d.com/Manual/Prefabs.html.

  13. In the Position Type property, select Multi Position_Mode.

    Topmost in the Inspector you'll find the Apply option. This will overwrite the currently saved Prefab, so unless you're using a version control system, be cautious about what Prefab you've been using. In this case, the 301_Torch_01 game object is identical to the saved Prefab, except for the lack of the AkAmbient component's Position Type property, and as such you can safely click Apply.

  14. In the Inspector, click Apply to send the new properties back to the Prefab.

    You have now saved the changes of the 301_Torch_01 game object into the 301_Torch Prefab which have made all other Torch game objects inherit the same properties.

  15. In Wwise, click Reconnect.

  16. In Unity, click Play to enter Play mode.

  17. In the game menu, teleport to the Dungeon.

  18. Run into the dungeon entrance corridor and back, while observing the sound of the torches.

    Notice that the Torch sounds are still positioned at their corresponding Torch game objects, like it was multiple AkEvent voices playing concurrently.

  19. Press ESC to open the WAG menu and click Play again to exit Play mode.

In Wwise, notice that the numerous Event instances have now been reduced to only 1, despite having provided the equivalent audio output.

In addition, if you were to add any torches to the Dungeon, you'd keep an instance count of 1 because you are using the MultiPosition Mode on any Prefab you add to a Scene. This makes the MultiPosition mode ideal for collaboration with level designers because the sounds are embedded into the objects, no matter where it's placed or moved, and without any additional audio performance expense.

[Note]

Keep in mind that the MultiPosition mode is only using one instance, so each sound position will be playing the same voice. As such, you cannot use the Randomizer to create sonic diversity between your sound positions.