// Update the Animator with the current state of the character controller public override void UpdateState(CharacterThirdPerson.AnimState state) { if (Time.deltaTime == 0f) { return; } // Is the Animator playing the grounded animations? animationGrounded = animator.GetCurrentAnimatorStateInfo(0).IsName("Grounded Directional") || animator.GetCurrentAnimatorStateInfo(0).IsName("Grounded Strafe"); // Jumping if (state.jump) { float runCycle = Mathf.Repeat(animator.GetCurrentAnimatorStateInfo(0).normalizedTime + runCycleLegOffset, 1); float jumpLeg = (runCycle < 0 ? 1 : -1) * state.moveDirection.z; animator.SetFloat("JumpLeg", jumpLeg); } // Calculate the angular delta in character rotation float angle = -GetAngleFromForward(lastForward); lastForward = transform.forward; angle *= turnSensitivity * 0.01f; angle = Mathf.Clamp(angle / Time.deltaTime, -1f, 1f); // Update Animator params animator.SetFloat("Turn", Mathf.Lerp(animator.GetFloat("Turn"), angle, Time.deltaTime * turnSpeed)); animator.SetFloat("Forward", state.moveDirection.z); animator.SetFloat("Right", state.moveDirection.x); animator.SetBool("Crouch", state.crouch); animator.SetBool("OnGround", state.onGround); animator.SetBool("IsStrafing", state.isStrafing); if (!state.onGround) { animator.SetFloat("Jump", state.yVelocity); } // the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector if (state.onGround && state.moveDirection.z > 0f) { animator.speed = animSpeedMultiplier; } else { // but we don't want to use that while airborne animator.speed = 1; } }
// Update the Animator with the current state of the character controller public override void UpdateState(CharacterThirdPerson.AnimState state) { if (Time.deltaTime == 0f) { return; } // Is the Animator playing the grounded animations? animationGrounded = true; // Crossfading if (state.moveDirection.z > 0.4f) { animation.CrossFade(moveName, 0.1f); } else { animation.CrossFade(idleName); } // Moving character.Move(character.transform.forward * Time.deltaTime * moveSpeed.Evaluate(state.moveDirection.z)); }
public virtual void UpdateState(CharacterThirdPerson.AnimState _state) { }