Game Development Reference
In-Depth Information
4.
Assign the Zombie Zone object to the Current Zone parameter.
5.
Click Play several times to see the random locations each time the prefab is
instantiated.
If you are having trouble locating the object in the scene, it will be named ZombieBunny(Clone) in
the Hierarchy view. You can click on it in the Hierarchy view to help locate it (Figure 7-31 ). You will be
randomizing its rotation later on.
Figure 7-31. The clone showing in the scene and Hierarchy view
With the location randomization working, let's see about adding more critters to the scene. But first,
since you will be populating gardens at different times, let's see about putting it in its own function.
Create a new function below the Update function:
1.
void PopulateGardenBunnies (int count) {
}
By having it take an argument, count , you can use it to populate gardens of different sizes
or difficulties.
Move the Instantiate lines from the Start function, and add them to the new
function.
2.
3.
Add a new variable to allow the difficulty to be changed more easily:
int litterSize = 10; // max base number of zombie bunnies to instantiate
4.
In the Start function, after the min/max assignments, call your newly created
function and pass it an argument using the litterSize variable, 10 in this case:
PopulateGardenBunnies (litterSize);
 
Search WWH ::




Custom Search