Game Development Reference
In-Depth Information
Figure 7-34. The ravening hoards overrunning the garden
It would be fun to stress out the player by triggering an audio cue that the zombie bunnies are about
to multiply. Because you calculated the random number before it was fed into the for loop, you can
delay the reproducing by a few seconds to give the audio cue.
Change the yield return new WaitForSeconds(adjustedTime) line to:
1.
yield return new WaitForSeconds(adjustedTime-3f); // pause 3 seconds before time's up
audio.Play(); // play the sound effect that signals the repro populating
yield return new WaitForSeconds(3f); // finish the adjusted time
2.
Save the script.
3.
From Components, Audio, add an AudioSource component to the Zombie
Spawn Manager object.
4.
Set its Volume Rolloff to Linear Rolloff.
5.
Uncheck “Play on Awake.”
6.
From the Sound FX folder, load the Stork audio clip in as its default clip.
Storks communicate by using a lot of beak clacking. This will tell the player that a new batch of
zombie bunnies are about to be deposited in the garden.
7.
Click Play, and listen for the stork heralding the arrival of more zombie
bunnies.
It would also be useful to know the current number of zombie bunnies…to put more pressure on the
player! Let's create a variable to keep count. In Chapter 9, you will incorporate the count in the GUI.
Search WWH ::




Custom Search