Lesson 6

Table of Contents

Using Events to Set States

You now have the Music_State State Group properly choosing the right music to play for the States you’ve configured so far. Cube’s game engine is not sending any information regarding the Music_State State Group to Wwise. Instead, it’s been programmed to send simple Event game calls at appropriate points in the game. For example, when the player goes through the second to the last teleporter in the level, this signifies the beginning of the Boss Fight and the game engine sends an Event call to Wwise indicating that the big fight is on. If you fight your way through the Big Boss and make it through the last teleporter, you’ve beaten the level and a different Event call is sent to Wwise signaling the player’s victory. You can use these Events to set the game state so that the appropriate music can be selected by the Wwise 201 Music Music Switch Container.

  1. In the Project Explorer, select the Events tab, Expand the Events folder, and select the Music Work Unit.

    To get a sense of the process, you’ll first create the Event for the boss fight. Because this is the name of a call coming from the game engine, the name used here must match perfectly with the name used for the Event in the game code.

  2. Click the Create New Event icon and name it Boss_Start.

    Now you need to use this Event to set the Music_State State Group to the Boss State.

  3. Select the Boss_Start Event and, in the Event Property Editor, click the Add>> button and choose States > Set State.

    A new row is created in the Event Property Editor.

  4. Right-click the empty area in the Target column and choose Set Target > Music > Music_State > Boss.

    Now do the same for when the player moves through the last teleporter and the map is completed.

  5. Create an Event named Map_Completed and use it to set the Music_State to Victory.

    The majority of the time the player will be in the general gameplay mode, which you’ve designated in Music_State State Group as the Gameplay State, which is currently set to play the Combat music. To ensure that the Wwise 201 Music Music Playlist knows to begin music playback in the Gameplay mode, you can add this information to the Music Event Action list.

  6. Select the Music Event.

    You can see where you’ve already set the Music Event to play the Wwise 201 Music. At the same time, you can tell it to set the Gameplay State.

  7. Add an Action to set the Music_State to Gameplay.

    While they occur almost instantly (unless otherwise modified by a Delay property), the order in which the Actions are carried out is listed from top to bottom. The Gameplay State should come first, so the State is properly set before playing the Wwise 201 Music object. You can drag the items in the Event Action list to set the order.

  8. Drag the Set State Action to the top of the list.

    The new order is established.

    Another thing to consider is that in some cases it’s possible that the Music Event might be transmitted multiple times especially when testing in Wwise. This would create a circumstance where multiple iterations of the Wwise 201 Music object could be playing simultaneously, causing music to play on top of music. To ensure that this doesn’t happen, you can add a Stop Event Action to shut down any music that’s playing, before starting any new music.

  9. Click Add>> and choose Stop > Stop.

    You need to indicate which object should stop playing. This can be done by dragging the desired object to the Target column.

  10. Drag the Wwise 201 Music object from the Project Explorer to the Target column on the Stop Action line.

    The Stop Action needs to occur first in the order of Actions so that any playing music is shut down before it’s started again.

  11. Drag the Stop Action to the top of the Action list.


Was this page helpful?