menu
Table of Contents
-
Modules
Now you have to think about how you’re going to start the heartbeat sound. Cube doesn't have a game call for this purpose. While you could ask the game programmer to add one, think about other ways you could accomplish the same thing without programmer involvement. You simply need an event that happens one time when the game is played.
You’re in luck since there is a game call that is sent from the game to the Wwise sound engine each time you start the game or load a new level.
-
In the Property Editor, right-click the Heartbeat object and click New Event > Play.
A new Event is created and opens in the primary editor. By default, it's named Play_Heartbeat based on the name of the Sound SFX object.
-
In the primary editor, change the name of the Event to Map_Loaded to match the name of the game call already coded in Cube.
Now when the game is launched, the heartbeat will be started. However, consider that if the player then loads another level, the Map_Loaded Event will be triggered again, causing a second heartbeat to play. If the player moves on to another level, a third heartbeat plays and so on. Because the heartbeat isn't heard until the player's health is low, the multiple heartbeat issue wouldn't be noticed unless the player's health declines. To solve this problem, you'll create two actions for the Map_Loaded Event, one to stop any existing heartbeat from playing and the second to then start the heartbeat.
-
Drag the Heartbeat object into the Map_Loaded tab in the primary editor.
A second Play Event is created.
The first thing that needs to happen when the Map_Loaded Event is received is to stop any heartbeat that might already be playing, even if its volume isn't loud enough to be heard. Just as you can use the Play action type to play a sound, you can also set an action type to Stop a sound.
-
In the first row, change the Type from Play to Stop.
It might look like both the Play and Stop actions will occur at the same time. However, the actions will occur in the order listed. So the heartbeat will first be stopped and then instantaneously restarted.
Now, each time the game is launched, or a new level is loaded, the heartbeat will be stopped before it is played, preventing the possibility of hearing multiple heartbeats during gameplay.
Next you'll use Cube to test your design. First you need to reload the map to call the Map_Loaded Event you just created, which will play the heartbeat sound.
-
In Cube, press Esc to open the game menu. Then select load map, press Enter, select map metl3 and press Enter again.
The same level loads, but you won't hear the heartbeat yet because the Wwizard still has full health.
-
Run forward and collect the red gem.
-
Press 3 to put the red gem in the Wwizard's staff, then stand close to a wall and click to fire the red gem.
This causes an explosion that bounces off the wall and injures the Wwizard. Notice his health meter in the lower-left corner declines.
-
Listen for the heartbeat sound. If you don't hear it yet, click again to lower the Wwizard's health further.
Notice his heart beats louder and clearer as his health declines.
When the Wwizard is defeated, you will continue to hear his heartbeat despite the States you configured in this module. This is because Cube wasn't designed to set the PlayerLife States. Instead, Cube sets Events, which you can use to set States in the Wwise project. This is a concept covered in the 201 certification. See Using Events to Set States for details.
If you would like to hear the heartbeat fade away in game, create the following Events:
-
Defeated_Player with a Set State action type, Target: PlayerLife\Defeated
-
Spawn_Player with a Set State action type, Target: PlayerLife\Alive
-
-
To exit the game, press Esc, use the up and down arrow keys to select quit, and then press Enter.
In this module, you learned to make a heartbeat sound slowly fade away when the player is defeated and quickly return when the player starts a new level. You started by creating a State Group with two possible States. You defined a transition time and then added the State Group to the Heartbeat Sound SFX. You configured the property changes you wanted to apply in either State, and then tested the results of the State change using the Transport Control. Lastly, you created an Event to stop and then play the heartbeat sound every time a map is loaded. This is a fantastic addition to the game. Great work!
Up next, Module 7: Profiling Game Syncs, where you'll learn to how to get a behind-the-scenes look at your Game Syncs.