Game Development Reference
In-Depth Information
You could have assigned the animator in the Start function, but this is a quick way to get the job
done with a one-off assignment.
10.
Click Play, and watch the action.
The reactivation causes the default animation clip to be reset. Each time the bundle is activated, the
Bundle Carry clip will be playing.
Watching the sequence play out, you are probably thinking it would be nice if the 3D zombie bunnies
didn't appear in the garden until the delivery was made (e.g., the bundle hits the ground). To do so,
you can take the call to repopulate and move it to the BundleManager script's OnCollisionEnter2D
function.
In the SpawnBunnies script, in the StartReproducing function, below the
DropBundle() line, comment out the PopulateGardenBunnies line.
1.
2.
Save the script.
3.
Open the BundleManager script.
4.
Add the following variables:
public int litterSize = 8; // Maximum litter size on spawning
public GameObject zSpawnManager; // where the SpawnBunnies script is
At the bottom of the OnCollisionEnter2D function, add:
5.
zSpawnManager.SendMessage("PopulateGardenBunnies", litterSize,
SendMessageOptions.RequireReceiver);
The litterSize is the argument that must be passed to the PopulateGardenBunnies function to tell it
the base number of zombie bunnies to make.
6.
Save the script.
7.
Assign the Zombie Spawn Manager to the Bundle's ZSpawn Manager
parameter in the Bundle Manager component, and click Play.
Now the zombie bunnies hold off popping into the scene until the bundle hits the ground.
The only thing missing from the sequence is a bunch of zombie bunnies bouncing out from the
opened bundle. . .
1.
Stop Play mode, and drag the last Bundle sprite, the baby zombie bunny, into
the Scene view, near the center top of the Game view.
2.
Rename it Baby ZB .
3.
Assign it to the Sprite layer.
Just as with the bundle, the Baby ZB will have a Rigidbody component so it can make use of
physics on landing. Additionally, you will be adding a Physic Material to its collider.
 
Search WWH ::




Custom Search