Leçon 5

Table des matières

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.

  9. Click OK.

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

  10. In the Capture Log's Game Object column, look for when the WeaponHolder's Surface_Type Switch is set for the first time.

Look for the first Switch to "Stone" message in the description column.

In the Game Object column, you will see that the Switch is being set on the WeaponHolder game object, which is the game object containing the Player's weapons. In the following row, the Player_WeaponImpact Event is played, which results in the impact on stone sound due to the Switch set just above. In the following rows the same Switch is being used for the Player_Footstep Event.

The Player repeatedly walks on grass or dirt, and as you will see in the Game Object column, the Switch is being set on a different game object, the toe_left and toe_right game object.

Lastly, as you start attacking the Stone again, notice that no Switch is being set on the WeaponHolder game object before thePlayer_WeaponImpact Event is posted, but it is still playing the impact on stone sound. This is because the Player_WeaponImpact Event is posted on the WeaponHolder game object and not any of the toes, where the Stone Switch has not been changed. As such, no matter on what other game object you might use the same Switch, the WeaponHolder game object will keep its Switch value. This demonstrates how you can effectively reuse Switches on multiple game objects without them affecting each other, as long as you make sure not to use the same game object.