Game Development Reference
In-Depth Information
Declares the angularSpeed variable and setting it with the result of the calculation direction/m_
DirectionResponseTime .
(13) m_Animator.SetFloat(m_SpeedId, speed, speedDampTime, Time.deltaTime);
m_Animator.SetFloat(m_AgularSpeedId, angularSpeed, angularSpeedDampTime, Time.
deltaTime);
m_Animator.SetFloat(m_DirectionId, direction, directionDampTime, Time.deltaTime);
Finally, now that you have determined the state of the animator and determined the appropriate
damping factors, you can set the animator's parameters. As you can see in the Scripting reference,
Animator.SetFloat accepts as arguments the name of the parameter, the new value for the
parameter, the time allowed for the parameter to reach the value (the smoothing factor), and the
current frame deltaTime .
If you want to dig in to more animation, Unity has a number of other examples with more animations,
controllers, and scripts and entire projects with sample scenes available for free on the Asset
Store. These are phenomenal working examples of common uses and best practices in animation.
Experiment with these, and don't be shy about searching for answers to your questions on the Unity
forums.
Summary
Whew—this chapter was pretty intense! You began with moving primitive game objects with scripts
that altered the transform.position and transform.rotation properties, then added user interaction
to drive the movement. You also learned to smooth these movement transitions with the Lerp()
function.
Next you reviewed Unity's Mecanim animation system and learned to animate character models
with animation clips driven with animator controllers. You went on to learn how to transition between
different animation states with Mecanim and corresponding scripts. During this process, you found
and utilized handy ready-made animation assets provided by Unity in the Asset Store.
Unity's Mecanim is a wonderful tool that makes learning and applying animations easier than ever
before. Nevertheless, this was no small endeavor—animating 3D models is still a career field in and
of itself. You definitely deserve a pat on the back for a job well done!
 
Search WWH ::




Custom Search