Lesson 3

Table of Contents

Events posted in Separate Scenes

[Note]

Before engaging this section, you must complete the previous section - Loading SoundBanks using Triggers.

Distributing game objects into separate scenes can have multiple advantages. One is that you minimize the amount of assets loaded concurrently; another is that you can activate an organized collection of different assets at the same time. Let's revisit the 'L3_1 - Loading SoundBanks using Triggers' Scene from the previous section, where you will find a Waterfall game object which we'll use to illustrate these advantages.

The Waterfall game object is the graphical rendering of the waterfall. As a child to it, you will find the Waterfall_UpClose game object which in turn has the Ambient_Waterfall AkEvent. As the Ambient_Waterfall Event is within the Woodlands SoundBank, it would seem logical that at least the Waterfall_UpClose game object should be in the Woodlands scene, but in fact the player cannot see the Waterfall until inside the Woodlands scene, and so it would be even more logical to put the entire Waterfall game object into the Woodlands Scene.

[Note]

While a child game object has a position relative to its parent, this does not offset the sounds positioning. Wwise will always account for the game objects position in the global space, as if the game object had no parent.

In the following steps, you will move the Waterfall game object to the Woodlands scene, so that the Waterfall game object will be activated and loaded along with the Woodlands Scene.

  1. In the Project view, search for Woodlands and drag the Woodlands Scene into the Hierarchy.

  2. In the Hierarchy, locate the Waterfall game object and select it.

    We only need to load the Waterfall game object (the Waterfall_UpClose parent object) while the player is in the Woodlands region, so let's drag it out of the Main Scene and into the Woodlands Scene.

  3. Drag the Waterfall game object, into the Woodlands Scene.

    That's all you need to do, as the rest of the Scene structure you set up earlier will take care of unloading and loading everything in the scenes. For good practice, let's use the Profiler's Voice Graph to profile the game and focus your attention to the Ambient_Waterfall Event to ensure it's being posted and stopped on Scene load.

  4. In Wwise menu, click Layouts and select Profiler.

  5. In the Advanced Profiler's Voices Graph tab, click the Filter's browse (...) button.

  6. Expand Events > Ambient > SoundBankSpecific and select the Ambient_Waterfall Event and click OK.

    By setting your filter to the Ambient_Waterfall Event, you will only view the Waterfall Event in the Voices Graph. Before you enter Play mode, make sure to remove the Scene as it will be automatically loaded.

  7. In Unity, first Save and then Remove the scene.

    When Profiling the game this exercise, it's advised to position Unity and Wwise side by side. If your screen resolution is too low, you can also try to detach the Advanced Profiler and position it next to Unity, as this is the main window you will need.

  8. Adjust your Unity and Wwise Project, so you'll see both side by side.

    [Note]

    By selecting Maximize on Play in the Unity Game view, entering Play mode will expand to the edges of the Unity editor, allowing you to more easily navigate in the game. While in Play mode, pressing Pause will temporarily restore the normal layout.

  9. In Wwise, click Remote…

  10. In the Remote Connections window, highlight the Wwise Adventure Game (Editor) and click Connect.

  11. Click Play.

  12. Run into the Woodlands Trigger, while keeping the Main Camera outside it.

    Notice that the Waterfall Event is still not active.

  13. Rotate the Main Camera inside the Woodlands Trigger.

    As you rotate the Main Camera into the Woodlands Trigger, the Woodlands Scene will be loaded, hereby posting the Ambient_Waterfall Event.

    [Note]

    If you don't see a red transparent mesh surface, please exit Play mode and go back to the previous exercise and position the Woodlands Trigger up close to the bridge.

  14. Rotate the Main Camera outside the Woodlands Trigger.

    As the Main Camera exits the Woodlands Trigger, the LoadSceneAsyncOnEnter script will notice it and, after a few seconds, unload and remove the scene along with the Ambient_Waterfall Event.

    With this way of organizing game objects in scenes, you ensure that the Event is loaded and unloaded with the corresponding SoundBank, just like you demonstrated using the profiler. To continue in this lesson, let's reset the Advanced Profiler's Voices Graph view and exit Play mode.

  15. In Wwise, next to the Filter, click browse (...).

  16. Topmost in the Filter, select None and click OK.

  17. In Unity, press ESC to open the WAG menu and click Play again to exit Play mode.


Was this page helpful?