Game Development Reference
In-Depth Information
if (_animator) {
if (_isJumping) {
if (IsGrounded) {
_motionState = MOTION_STATE.FALL;
} else {
if (_motionState == MOTION_STATE.GROUND) {
_motionState = MOTION_STATE.JUMP;
} else if (_motionState == MOTION_STATE.JUMP)
{
_motionState = MOTION_STATE.JUMP_HOLD;
}
}
} else {
if (IsFall) {
_motionState = MOTION_STATE.FALL;
} else {
_motionState = MOTION_STATE.GROUND;
}
}
Vector3 velocity = new
Vector3(_hDirection,0.0f,_vDirection);
velocity.y = 0.0f;
_animator.SetFloat ("Speed",
velocity.sqrMagnitude);
_animator.SetBool ("IsRun", _isRun);
_animator.SetInteger ("MotionState",
(int)_motionState);
}
}
Note
The OnAnimatorMove() function is the callback function that will be called
each frame after the state machines and the animations have been evaluated. We
can say that this is very similar to the FixedUpdate() function. However, the
OnAnimatorMove() function will make sure that all the parameters will be
got and set correctly before we do something.
Search WWH ::




Custom Search