Game Development Reference
In-Depth Information
Add the same line in the ManageSlug function under the running = true line.
5.
Change the 90 in the SlugManager conditional to slugTime :
6.
if (percentRemaining == slugTime && !running) {
7.
Save the script, and save the scene.
8.
Play through from the StartMenu scene, and test.
The player is now given a reprieve when the zombie bunnies have gotten out of hand.
Feel free to experiment with the functionality. You may decide that the battery should be reset only
once, so you can comment out the line that resets the battery in the SlugManager script. Or you may
want to experiment with multiple runs and variable speeds. To adjust the speed of the Slug clips, you
would set animator.speed for the slug's animator component.
Upgrading the Armaments
In this final section, you will be revisiting Mecanim for a look at custom masking. You may remember
that one of the animation clips opens the gnome's hat to expose what looks to be a laser beam
device. Once the ability to do so is added to the game, you will be adding the beam through the very
useful physics raycast functionality.
Mecanim Masks and Layers
Masks let you isolate parts of the character and control them with different animation clips. To
activate a layer, you generally create a Parameter (which is essentially a variable), in the state engine
and call it from a script. Let's start by defining a mask.
1.
Open the GardenLevel1 scene.
2.
In the Animated Assets folder's Animator Controllers folder, right-click, and
from Create, select Avatar Mask.
3.
Name it Hat Node Mask .
4.
In the Inspector, click on Humanoid.
A humanoid body template appears. With humanoids, the bone systems are similar so that masks
can be used on any humanoid character. The gnome character doesn't even have bones, so you will
make a custom mask from its skeleton.
5.
Close the Humanoid section, and open Transform.
6.
Load the GardenGnomeAvatar in the “Use Skeleton from” field, and then
click the Import Skeleton button.
The GardenGnome's hierarchy appears in the panel.
7.
Click the Gnome Motion Root check box to clear the selections, and then
click the Hat Node to define the masked parts (Figure 11-11 ).
 
Search WWH ::




Custom Search