6.3 Creating Interaction

 

6.3) Creating Interaction

 
 

 

Thus far, dynamic change for the Music System has been driven primarily by randomization within a Playlist Container. For music to be truly dynamic, something the player is doing in the game should drive decisions about how the music sounds. This could be that when a player scores a goal, celebratory music is heard; and when a driver accelerates, guitars roar with the car’s motor; or when a certain weapon is wielded, its unique theme is played. For the game to have this kind of interactivity, Game Calls delivered from the game engine to Wwise need to be tied into the Music System. The Game Calls can be conventional Calls such as Events, Game Parameters, Switches and States, or specialized Calls designed specifically for music applications called Triggers, which you’ll be exploring later. Different types of Calls can act on the music in different ways. The most important type is almost certainly a State Call. It can be used for defining paths similar to a behaviour tree for the Music System to react to different gameplay situations. These States can then be used to create smooth Transitions between different Music Segments or Music Playlists.

Pic01 Music States

Pic02 Music Switch Container

Pic03 Music Switch Tempo

Pic04 Associate States

Pic05 Associate Playlists

Pic06 Connect Play Event

Pic07 Connect Stop Event

Pic08 Transport Control View

  1. Go to the Game Syncs Tab in the Designer Layout.

    If you have checked the Capture Log of the Profiler every once in a while, you probably noticed that there are still some “Unresolved” API Calls for setting a State. The reason for this is yet another State Group that has already been implemented by the Audio Programmer, for the sole purpose of creating a Dynamic Music System.

  2. Select the Default Work Unit in the States Folder and create a new State Group called Music.

  3. Create two States for the State Group and name them Start and End. (Pic01 Music States)

  4. Go back to the Audio Tab where the Interactive Music Hierarchy is located, select the two Music Playlist Containers, right-click the selection and choose New Parent > Music Switch Container. Alternatively you could also select the Default Work Unit of the Interactive Music Hierarchy, create a new Music Switch Container and make the Music Playlist Containers child Objects of the Music Switch Container. (Pic02 Music Switch Container)

  5. Name the Music Switch Container music. You can also create a Virtual Folder inside the Default Work Unit of the Interactive Music Hierarchy and drag all Music Objects into it, if you like it nicely organized. Make sure that the Music Switch Container is then routed to the Music Bus.

    Music Switch Containers have Time Settings for Tempo and Time Signature that will override those same settings in the Playlist Containers that are now contained within. This will cause significant issues in how Playlist Containers transition between each other as all of the Entry and Exit Cues will no longer match the music. For this reason, you need to override the Time Settings for all of the contained Playlist Containers if they contain music in varying Tempo and Time Signature. In your case, all music snippets have the exact same Time Settings, so you only have to set the Tempo and Time Signature for the Music Switch Container, which is then inherited by all child Playlist Containers.

  6. Select the Music Switch Container and set the Tempo to 124 BPM. (Pic03 Music Switch Tempo)

  7. Switch to the Interactive Music Layout. It is now time to connect the Music Switch Container to the Music State Group you’ve just created in order to set the right Playlist Container for each State.

    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.

  8. In the Music Switch Container Association Editor, click the selector button and choose State Groups > Music. (Pic04 Associate States)

    To associate a piece of music with a particular State, you simply drag the desired 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 designate which association you’re about to make.

  9. Drag the start Playlist Container to the Start State and the end Playlist Container to the End State. Please take note of the None State, which is created by Wwise automatically for each State Group. (Pic05 Associate Playlists)

    In the lower part of the Music Switch Container Association Editor you’ll see two rows. The second one indicates that when the player is starting a new run, the start Playlist Container will be selected. The first row shows that when the player is in the finish line, the end Playlist Container will be selected. One such row of information is referred to as a Path. Now Wwise knows exactly what music to play in which Game State.

    Think of each Path as a rule for the Music Switch Container to follow. When the Music Event triggers the 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 Objects to play. This list of paths can 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 the your work to see if the appropriate music plays.

  10. In the Project Explorer click the Events Tab, expand the Music Folder in the Default Work Unit and select the Play_music Event. Add a Play Action and add the Music Switch Container as Target. (Pic06 Connect Play Event)

  11. Repeat this for the Stop_music Event, but with a Stop Action and a short Fade-out. (Pic07 Connect Stop Event)

    Remember that the condition of the State Group now factors into which piece of music is played. As soon as you select the Play_music Event with its newly set Target, the status of that State Group and State will now appear and can be adjusted in the Transport Control View. You have to select States to display all State Groups connected to the Target of that Event. (Pic08 Transport Control View)

  12. Hit the Play Button in the Transport Control View and change States from Start to End while listening.

    You’ll notice that sooner or later, the Music changes to the end Playlist Container. This is good because it means that your Music System is working correctly. The only bad thing about it is, that the timing for that change is rather unpredictable and hence it doesn’t sound very smooth at all. In the next chapter you will learn how to create smooth transitions whenever a State change within the Music System occurs.