Game Development Reference
In-Depth Information
1.
Create a new variable with the other variables:
int currentBunCount = 0; // current number of zombie bunnies
To be able to add all of those random amounts, you need only track the PopulateGardenBunnies
function.
In the PopulateGardenBunnies() function, directly above the print statement,
add the following:
2.
currentBunCount += count; // add the lastest count to the current total
In the print statement, replace count with currentBunCount .
3.
4.
Save the script.
5.
Click Play, and watch current count being incremented in the console as new
zombie bunnies are instantiated into the scene.
Spring Planting
Now that the zombie bunnies are under control, or out of control in this case, you may want to find
room for some of the vegetable prefabs you created in Chapter 4. Unlike with the zombie bunnies,
you will want these laid out in neat rows.
Nested Loops
Once again, you will make use of a for loop, but this time, to get nice evenly spaced rows, you will
embed or nest one for loop inside the other. Think of one loop for the rows and the other for the
columns. Just as with the Zombie Zone, you can define a Bed Zone with a cube. This time, however,
you will be using its y value to determine ground level.
1.
In an overhead ortho view, create a cube to cover the inner part of one of the
Raised Bed objects (Figure 7-35 ).
 
Search WWH ::




Custom Search