Game Development Reference
In-Depth Information
Declares an Animator type reference variable with a null value.
(2) private var m_SpeedId : int = 0;
private var m_AgularSpeedId : int = 0;
private var m_DirectionId : int = 0;
Declares int type variables for parameter IDs, for use as a hash identifier . Hash identifiers won't be
covered in detail here, but they are another way to reference parameters using integers instead of
strings. Using a hash identifier is more efficient, so it contributes to improved performance.
(3) public var m_SpeedDampTime : float = 0.1f;
public var m_AnguarSpeedDampTime : float = 0.25f;
public var m_DirectionResponseTime : float = 0.2f;
Declares float type variables and set with default values. These are smoothing factors for the various
animation transitions.
(4) function Locomotion(animator : Animator)
{
m_Animator = animator;
m_SpeedId = Animator.StringToHash("Speed");
m_AgularSpeedId = Animator.StringToHash("AngularSpeed");
m_DirectionId = Animator.StringToHash("Direction");
}
The Locomotion() function accepts an Animator argument and with this sets the values of the
previously declared animator and parameter ID variables.
(5) function Do(speed : float, direction : float)
The Do() function accepts two float arguments speed and direction.
(6) var state : AnimatorStateInfo = m_Animator.GetCurrentAnimatorStateInfo(0);
Declares an AnimatorStateInfo reference variable state and sets it with the state of the Animator.
With this you have more detailed information on the current animation state, such as length of the
animation state, whether or not it is looping, and more.
Remember You can use +' to open the Scripting Reference for more details, such as the complete list of
variables and functions available through AnimatorStateInfo.
(7) var inTransition : boolean = m_Animator.IsInTransition(0);
 
 
Search WWH ::




Custom Search