Lesson 6

Table of Contents

Using a State with Transitions

While it might be sad to think about, at some point our player may be defeated—it’s an inevitable reality. A brief and simple piece of music has been composed and imported into the project just for this occurrence: the Defeated Music Playlist Container. A global idea like the player being alive or defeated is often addressed in the game engine as a state. The status of that state may drive many decisions about what might happen visually on the screen and can also drive how sound, including the music, might be heard. For example, this Wwise project already has a State Group game sync called PlayerLife. It was originally put in place to handle non-musical aspects of the audio integration for the sound effects. Currently when the player is defeated, all of the sound effects are filtered to muffle their sound. You can use this same State Group to determine which music is played.

[Tip]

Refer to the Wwise-101 course, Lesson 3 to review the application and configuration of State Groups and States.

  1. In the Interactive Music Layout, select the Wwise 201 Music Music Switch Container.

    In the lower-right corner, you see the Music Switch Container Association Editor. This is the place where you define how the status of State Groups or Switch Groups should be used to decide which piece of music to play. The status of the player’s life is indicated by the PlayerLife State Group.

  2. In the Music Switch Container Association Editor, click the [>>] selector button and choose State Groups > PlayerLife.

    You see a column representing the PlayerLife State Group appear, with all of its possible States listed below.

    To associate a piece of music with a particular State, you simply drag the desired Music Playlist Container from the Project Explorer to the State listed in the Music Switch Container Association Editor. The destination State will temporarily turn blue to indicate which association you’re about to make.

  3. Expand the Wwise 201 Music Music Switch Container and drag the Combat Music Playlist Container to the Alive State.

    In the lower part of the Music Switch Container Association Editor, you’ll see a row that indicates that when the player is Alive, the Combat Music Segment will be selected. This row of information is referred to as a Path. Now Wwise knows to play the Combat music if the player is alive. Now you need to indicate what music to play if the player is defeated.

  4. Drag the Defeated Music Playlist Container to the Defeated State.

    A new Path is created. Think of each Path as a rule for the Music Switch Container to follow. When the Music Event triggers the Wwise 201 Music Music Switch Container, it then looks at the condition of any State Group that is being referenced and then follows all of the rules to decide which object to play. This list of paths will become longer and more complex as you start adding additional States Groups and Switch Groups as variables into the mix.

    Now it’s time to test your work to see if the appropriate music plays. Remember that the condition of the PlayerLife State Group now factors into which piece of music is played. Now that you’ve associated this PlayerLife State Group with the Wwise 201 Music object, that status of that State will appear and can be adjusted in the Transport Control view.

  5. If it’s not already selected, click the States button in the Transport Control view.

    You can simulate the condition of the State Group by adjusting it in the Transport Control.

  6. Set the PlayerLife State Group to Defeated and play the Music Event.

    You hear the Defeated music.

  7. Set the PlayerLife State Group to Alive.

    You hear the Combat music.


Was this page helpful?