Game Development Reference
In-Depth Information
Figure 7-39. The veggies ravaged by zombie bunnies
Parenting
There's one last thing to be done to wrap up this chapter. Between the plants and the zombie
bunnies, you've added quite a bit of geometry that should eventually be hidden by your occlusion
system. This means you will want to see about getting all of the clones parented. The most obvious
parent is the object that defines the zone. Fortunately, parenting is a simple operation performed on
the object's transform, not the gameObject itself.
1.
Open the SpawnBunnies script again.
The SpawnBunnies script uses the Zombie Zone object to place the zombie bunnies, but due to
their mobile nature, you won't want any mishaps with inherited scale distorting them. The safest
parent will be an empty gameObject with its default scale of 1 x 1 x 1.
Create a new Empty GameObject, and name it Bun Holder .
2.
3.
In the SpawnBunnies script, add a variable to store the object's transform:
public Transform bunHolder; // to parent the instantiated zombie bunnies to
Add the following line below the zBunny.GetComponent<Animator> line of the
SpawnBunnies script:
4.
zBunny.transform.parent = bunHolder; // assign the clone to this object's transform
5.
Save the script.
6.
Drag the new Bun Holder object onto the Bun Holder parameter in the
Spawn Bunnies component.
 
Search WWH ::




Custom Search