public void FixedUpdate() { if (m_pause) { return; } // m_onControllerColliderHitAlreadyCalled = false; if (launcher == null) { launcher = GetComponent <AttackLauncher>(); } if (launcher.isAnyBusy()) { return; } Vector3 direction = transform.forward * m_forwardSpeed + transform.right * m_rightSpeed; direction.y = m_yVelocity; if (direction.z == 0 && direction.x == 0) { m_Animator.SetBool("Idle", true); } else { m_Animator.SetBool("Idle", false); } Vector3 newDir = transform.InverseTransformDirection(direction); m_Animator.SetFloat("Forward", newDir.z, 0.1f, Time.deltaTime); m_Animator.SetFloat("Turn", Mathf.Atan2(newDir.x, newDir.z), 0.1f, Time.deltaTime); m_Animator.SetFloat("Jump", m_yVelocity); float runCycle = Mathf.Repeat(m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime + 0.2f, 1); float jumpLeg = (runCycle < 0.5f ? 1 : -1) * newDir.z; if (m_controller.isGrounded) { m_Animator.SetFloat("JumpLeg", jumpLeg); } if (m_controller.isGrounded && direction.magnitude > 0) { m_Animator.speed = 1f; } m_controller.Move(direction * Time.deltaTime); m_Animator.SetBool("OnGround", true); // --------------------------------------------Take a hit -------------------------------------------------- if (!m_tookAHit) { return; } Vector3 speed = m_velocityHit; if (m_controller.isGrounded) { m_yVelocity = 0; m_velocityHit.y = 0; } else { m_yVelocity -= m_gravity; } speed += Vector3.up * m_yVelocity; if (m_controller.isGrounded && m_speedFrictionHit != 0) { Vector3 friction = -speed.normalized * m_speedFrictionHit; if (Mathf.Sign(speed.x + friction.x) != Mathf.Sign(speed.x)) { speed = Vector3.zero; } else { speed += friction; m_velocityHit += friction; } } if (speed.magnitude < 1) { m_tookAHit = false; } m_controller.Move(speed * Time.fixedDeltaTime); // --------------------------------------------End take a hit -------------------------------------------------- }