Audiokinetic Wwise Knowledge Base

Should we be using switches or states?

Switches and states can both be used to determine what in a Switch container will be played.

The main difference is the switch can be different for each game object of the game while the state is a global variable of the game and is the same for everything at one time.

Common mistakes:
#1: Using switches when you could be using states.

Whenever possible, you should use states because they require less memory and are faster.
The only situation where it would be required to use switches instead of states is if it is possible for a switch to be different for two different object at one time.
For example:

  • Weather (sunny, raining, windy, fog, ...) should be a state.
  • GroundTexture (concrete, grass, sand, ...) for determining footstep sound should be a switch.


Note: This is not true with interactive music switch containers. Switches and states require the same amount of memory when used with a music switch container. Moreover, the music hierarchy needs to be searched every time a state changes and music is playing, in order to compute delayed state changes (see http://kb.gowwise.com/questions/177/Using+States+with+the+Interactive+Music+Hierarchy). Thus, switches are preferred when it comes to interactive music objects.

#2
Duplicating containers (and all their children) to apply different parameters on children based on states.

States may be used also to modify parameters (volume, pitch, Low pass filter...). Simply click on the state tab, select the state group and set the parameters to be modified for each state independently.

Duplicating structure will potentially require more memory at run time, and most of the time it should be avoided.




Article Details

Last Updated
22nd o February, 2010

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions (0 votes)

No users have voted.

How would you rate this answer?



Thank you for rating this answer.

Related Articles

No related articles were found.

Attachments

No attachments were found.

Continue