Game Development Reference
In-Depth Information
9. Now, in the last function of this CharacterControl script, we will add the
OnAnimationMove() function to control the state of our animation. So, let's
add the following code:
// Unity JavaScript user:
function OnAnimatorMove (){
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;
}
}
var velocity: Vector3 = new
Vector3(_hDirection,0.0f,_vDirection);
velocity.y = 0.0f;
_animator.SetFloat ("Speed",
velocity.sqrMagnitude);
_animator.SetBool ("IsRun", _isRun);
_animator.SetInteger ("MotionState",
parseInt(_motionState));
}
}
// C# user:
void OnAnimatorMove (){
Search WWH ::




Custom Search