Lesson 2

Table of Contents

Attenuation Spheres

While the Ambient_Windmill Event has been added to the Scene as an AkAmbient component, one last detail remains to be fixed - the distance attenuation of the Windmill. From the player's starting position, the Windmill sound is completely inaudible due to the listener game object (Main Camera) being outside the maximum attenuation radius of the Ambient_Windmill Blend Container.

[Tip]

For more information about the Wwise Unity Integration listener (AkAudioListener), visit Lesson 9.

As such, let's increase the Max Distance of the Ambient_Windmill's Attenuation ShareSet. But, how much should you increase it? And how do you make sure the player is able to hear it from the starting position? One solution is using Attenuation Spheres.

When enabled in the AkAmbient component, the Attenuation Sphere will display a sphere with the radius from the center of the game object to the maximum attenuation distance set in Wwise. With this sphere you get a visual representation of the Max Distance set in the Attenuation Editor, so you can evaluate the distance in comparison with in-game objects.

In the following steps, we'll enable and configure Attenuation Spheres in the Wwise Adventure Game.

  1. In the Unity menu, go to Audiokinetic > Certification > 301 > Lesson 2 and select Attenuation Spheres.

  2. In the Hierarchy, go to L2_2B - Village Environment Scene, expand Wwise, and select the Windmill game object.

  3. In the attached AkAmbient component, set the Show Attenuation Sphere property to Current_Event_Only.

    By selecting the Current_Event_Only option, you would expect to see a red sphere representing the Attenuation in the Scene view, but you do not. By default these Max Distance values in the Attenuation ShareSets are not included as metadata in the SoundBanks, so to be able to generate the spheres you need to visit the SoundBank Settings.

  4. In Wwise, select Project > Project Settings.

  5. Select the SoundBanks tab.

  6. In the SoundBanks tab, enable Max Attenuation.

    The Wwise Unity Integration will now be able to fetch all Max Distances from all Attenuation ShareSets and use it to determine the size of the Attenuation Spheres.

    [Tip]

    By calling the AkWwiseProjectInfo.GetData().GetEventMaxAttenuation() function, you can fetch the Max Distance for your own custom script.

  7. In the Project Settings, click OK.

    While you might know how to generate SoundBanks from Wwise, you can also generate SoundBanks from the Wwise Picker in Unity.

  8. In Unity, locate the Wwise Picker and click Generate SoundBanks.

    Clicking Generate SoundBanks will generate all SoundBanks for all platforms and languages. This process may take a while. A sphere will now appear on the selected Windmill game object.

  9. Use the Hand tool ('Q') to position the Scene view looking at both the Windmill and Main Camera.

    Notice that the sphere is not reaching the player's starting position where the Main Camera is located, and so the Windmill would be completely inaudible. Let's head into Wwise and adjust the Attenuation.

  10. In Wwise, search for 'Windmill' and select the Ambient_Windmill Blend Container.

  11. In the Positioning tab, click Edit.

    In the Attenuation Editor's Max distance field, you'll find a current Attenuation distance of 35, corresponding to the size of the sphere in Unity.

    What should you set it to? One approach would be to increase it while repeatedly switching between Unity and Wwise to see the result. A more precise approach would be to temporarily use the radius of a Sphere Collider.

  12. In the Unity Inspector, go to the Sphere Collider and set the Radius to 35.

    In the Scene view, you will now see a green line at the edge of the Attenuation Sphere. As long as the game object is not scaled (increased or decreased in size), the Radius of a Sphere Collider translates directly to the Attenuation's Max distance property. By increasing the Sphere Collider Radius, you will be able to visualize the distance required by the Attenuation to reach the Player.

  13. Click and hold the Radius property and drag it to the right until the green Sphere Trigger is reaching the Player.

    Once you've found a suitable value, you can use that value in the Attenuation ShareSet's Max distance field.

  14. Switch to Wwise and in the Attenuation Editor, set the Max distance to the new Sphere Collider Radius's value (rounded up).

    As we are only using the Sphere Collider to get a temporary measurement, let's set it back to 1.

  15. In the Unity Inspector, locate the Sphere Collider and set the Radius property to 1.

    Lastly, you need to fetch the most recent changes from the SoundBanks.

  16. In the Wwise Picker, click Generate SoundBanks.

    Generating the SoundBank from within the Unity's Wwise Picker will also update the Unity project with the latest information from the Wwise Project.

Notice that the Attenuation Sphere has increased in size and now covers the Player's starting position.

As such, you are able to evaluate exactly how far the attenuation would reach in Unity.


Was this page helpful?