Game Development Reference
In-Depth Information
In the Update function, above the Translate line, add the “stop” condition:
7.
if (transform.localPosition.x < endLocation.x) gameObject.SetActive (false);
// deactivate
8.
Save the script.
9.
Click Play, and watch the stork in the Hierarchy view to make sure it is
deactivated after it goes out of view in the Game window.
The stork fly-by will be initiated in the Zombie Spawn Manager's SpawnBunnies script.
1.
Open the SpawnBunnies script.
2.
Add the following variable to access the stork:
public GameObject stork; // the Stork Group
In the StartReproducing function, just above the audio.Play() line, add:
3.
stork.SetActive (true); // reactivate the stork
stork.SendMessage ("Initialize", SendMessageOptions.DontRequireReceiver); // initialize
the stork
4.
Save the script.
5.
Assign the Stork Group to the Zombie Spawn Manager's Stork parameter.
6.
Click Play, and watch the stork fly by with each new zombie bunny addition.
With the stork now making a fly-by, you will want to move the Clacking sound effect to the stork and
set it to looping.
7.
Add an Audio Source component to the Stork Group.
8.
Load the Clacking clip, turn “Play on Awake” on and set the clip to Loop.
9.
Disable or remove the Audio Source component from the Zombie
Spawn manager.
In the SpawnBunnies script, change the audio.Play() line to:
10.
stork.audio.Play(); // play the sound effect that signals the repro populating
11.
Save the script, and click Play to test the sound effect.
The clacking sound effect now matches up with the stork's fly-bys.
Next up is the stork's payload: a bundle of Zombie bunnies. You will do the usual sprite slicing, but
this time, you will be using Mecanim and key-frame animation to cue the action. Unlike a “canned”
animation, by animating the various parts individually, you will be able to cue the bunny-drop
sequence at any (random) time.
 
Search WWH ::




Custom Search