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 5

Table of Contents

Switches

In the the previous section, Setting a Switch using a Wwise-Type, you were asked to set the Surface_Type Switch for the Player's footsteps. Another Switch Container using the same Switch Group is the Impact_Weapon_Type Switch Container, called when the Player's weapon impacts on a surface. Both the Footstep_Surface and Impact_Weapon_Type Switch Container are performed by the Player and make use of the same Switch Group, so what happens when you alternate between moving and attacking? How do these two Switch Groups not interfere with each other?

In the following steps, let's capture a Profiler Session and look at the Switch changes. As you are not going to change properties or Scene assets, you can use the Main Scene, which is the complete version of the game.

  1. In Unity, go to Audiokinetic > Game Scenes and select the Main Scene.

  2. Click Play to enter Play mode, and then Connect Wwise to the WAG.

  3. Press E to skip the dialogue until you see the Adventurer in the Game view.

  4. Run over and attack a nearby stone in the Training Area.

  5. Take a few footsteps, on both grass and dirt, and hit a stone again.

  6. Click Play again to exit Play mode.

  7. In Wwise's Capture Log, click on Filter...

  8. Disable all Types, except for Switches and Events and click OK.

    Let's now take a closer look at the Capture Log.

  9. In the Capture Log's Wwise Object column, find the first log entry of the Player_WeaponImpact Object and notice the Surface_Type Switch set above.

    As the Player's Sword impacts the Stone, the Surface_Type Switch will be set to Stone and you will hear the weapon impacting on stone.

    Notice that shortly afterwards, the Surface_Type is set to Grass. This time the Switch is used by the Player_Footstep Switch Container. Remember that, while searching for the second Player_WeaponImpact.

  10. In the Capture Log's Wwise Object column, find the second log entry of the Player_WeaponImpact Object.

This time, you hear the Weapon impacting on stone again, even though the last Surface_Type Switch log entry is Grass. This is because the Grass Surface_Type is set on the Player's toes (the toe_left and toe_right game object) which is not the same game object used by the Player_WeaponImpact. Instead, the Player_WeaponImpact is posted on the WeaponHolder game object, which is unchanged from when it was set to the Stone Surface_Type Switch. This demonstrates how you can effectively reuse Switches on multiple game objects without them affecting each other.