5.3) State Groups and States
States are yet another specialty Game Sync that are typically used to make sweeping transitions to the game’s audio in reaction to a global event in the game. For example, a State can be used to identify if the player is conscious or unconscious, above or below water, in one or another area of the level. The status of the State can be used to offset Object Property values such as the Volume, Low- and High- Pass Filter in order to change the sonic texture of the game.
Similar to Switches, State Groups and States have already been implemented in the Platformer Game’s code. There are three State Groups implemented, one for changing the music depending on where the player is at a given point in time (you’ll explore this in the next lesson of this course), one for changing the atmospheric sounds depending on the Player Character’s location, and one simply for changing the mix of elements whether the player is currently trying a run, or is in a menu or on the highscore screen.
First open the Profiler and set the Filter to filter only States and API Calls for Game Syncs.
Play the game and make a complete run-through.
Now let’s check out the Capture Log of the Profiler.
You can see that there are API Calls for setting a State, but again it reads “Unresolved” because you haven’t created any States in your Wwise project yet. (Pic01 Profiling States) That’s why you’ll be creating the first of three State Groups to change the atmospheric sounds depending on the Player Characters location.
Go to the Game Syncs Tab in the Designer Layout.
Select the Default Work Unit in the States Folder and create a new State Group.
Again, the Audio Programmer has already implemented the State Group (and States), so it is important to match the name for these Objects. Set “PlayerLocation” for the State Group’s name. (Pic02 Create a State Group)
Create two States for the State Group and name them "Shopping” and “Traffic”. (Pic03 Create States)
The idea is to make a subtle sonic change whenever the Player Character is moving away from the street, running in front of the big skyscrapers through a shopping zone. This change really has no deeper gameplay meaning, but it keeps things acoustically interesting and fits nice to the general style of the game.
Play the game, start profiling and make another run-through.
Check the Capture Log again, your State Group and the States are now displayed.
So let’s use them creatively. To recap: Switches allow a change in sound for all Game Calls following a Switch change. States on the other hand give you the chance to nicely transition from one sound or a group of sounds to another, within a time controlled by you. For changing the atmospheric sounds between your two states we therefore need to set either a Default-, or a Custom Transition Time for individual transitions.
Set a Default transition time of 3 seconds. This should work fine. (Pic04 Transition Time)
Now that you’ve set up your State Group and States with the desired transition time, you need to identify which Properties of Objects you want to change when the PlayerLocation state changes. If you go back to the Project Explorer and open the level01 Blend Container, you can see that you have a wind Random Container and two Blend Containers named shopping and traffic. As you might conclude, you have already set up all Objects in the Actor-Mixer Hierarchy to make a distinction between the two locations the player can be in. The shopping Blend Container includes high heels footsteps, dogs barking and a general stereo bed of a shopping street, the traffic Blend Container car horns and a general stereo bed of a busy street in a city. Lets connect these Objects to the State Group and decide what should be heard and how loud in which state.
Select the traffic Blend Container and click the States Tab in the Property Editor. (Pic05 States Tab)
Now click Add State Group >> and select the PlayerLocation State Group.
You can now create a offset for various Properties depending on which State is called by the game. Look and scroll right to view all available Properties that can be adjusted by a State change. You can even add more Properties if you really want to dig in and get specific. (Pic06 Properties)
You will keep it simple and just choose an offset for the Voice Volume and Voice Low-pass Filter of this Blend Container. Before you change anything, think it through!
If the Traffic State is called by the game engine, you actually don’t want to offset a Property of this Blend Container, so you can still hear all the car horns and traffic noises. What you want to do is offset the Voice Volume and Voice Low-pass Filter of this Blend Container whenever the Shopping State is called. Therefore you can turn down the Voice Volume for the Shopping State, to make traffic noises a lot quieter whenever the Player Character is moving through a shopping ares in the level. And you can turn the Voice Low-pass Filter up a bit to filter out high frequencies to make the sound a bit duller and create the illusion that the traffic is now further away. (Pic07 Adjusting Voice Volume + Voice Low-Pass Filter)
Now click on the shopping Blend Container and turn its Voice Volume down for the Traffic State, to not hear any footsteps, dogs or shopping street noises whenever the Traffic State is called by the game engine. (Pic08 further Adjustments)
Great! This are all the steps to make a sound or a group of sounds change whenever a state change is happening. Imagine doing this on a greater scale for bigger projects with a great number of conditions. Before continuing with this lesson, let’s quickly look at a way to preview if the State change sounds as intended.
Click the level01 Blend Container, which is triggered by the Play Action of the atmo Event.
Look at the Transport Control below. It offers a way to not only play back an Object, but choose the condition for the playback. It can simulate a Game Call so you know what to expect if the game engine makes such a call. You can also notice a third State called “None”, which is automatically created by Wwise. In the None State, all the sounds are played back. The None State is set automatically by the Wwise Audio Engine, if there is no State Call in the game code. (Pic09 Transport Control)
Click play and switch between States. Listen at the transitions. (Pic10 Previewing State Transitions)
If you’d like to change things up, then go ahead. You’ll probably have to make the wind quieter, so you can better listen to the transitions and make the atmo generally sound more clear.