With the mask ready and set up, we can move back to the Animator panel to add a second animation layer. Be ready to follow our instructions.
We follow on from where we left off . The avatar mask is ready to be used with the second animation layer.
layer
, as shown in the following screenshot:UpperBody
, the same as the mask.1
. This is sort of a default value; you may need to tweak it according to each of your actual animation clips.trigger
, or a boolean
parameter like we used before; make a transition between the default state of UpperBody and reload; and finally, add instructions to the AnimController
script to trigger the animation upon reloading the weapon.boolean
parameter called bReload
, the line of code to be added would be:charAnimator.SetBool ("bReload", true);
Mask blending and displacing animation clips on different layers is a technique that both allows you to create more complex animation trees for game characters while keeping the number of actual clips to be crafted at a minimum. In our case, we set a new layer to act only on the arms of the character and applied a reload animation clip to them, while the rest of the character's body keeps running, walking, or whatever.
As usual, we recommend you check out the manual for the more advanced settings, available at http://docs.unity3d.com/Manual/AnimationLayers.html.
Mecanim is one of the most relevant improvements to Unity in recent years. There is really very much you can achieve with it, especially if you plan to use humanoid characters for full 3D games.
An option we didn't discuss in this chapter is retargeting, which allows you to adapt a complete animation set to different characters with similar skeletal configurations. Retargeting is an efficient and economic way, for example, to offer your players the option to choose between male or female characters to play with. Instead of making a complete new animation set for the additional characters, you just retarget the set you have!
We suggest you refer to the Unity documentation to learn more about the animator component, its features, and its methods. The manual is available at http://docs.unity3d.com/Manual/AnimationSection.html.
We suggest this tutorial (http://www.digitaltutors.com/lesson/27480) about character animation.
It is hosted by Digital Tutors: it is excellent, clear and quickly puts you on the track, though it comes with a price!
18.116.62.168