private void CalculateMovementDirection(float absHorizontalInput, float absVericalInput) { float running = Input.GetAxis("Running"); float runningModifier = runningHandler.GetIsRunningModifier(running); float actualSpeed = Mathf.Max(absVericalInput, absHorizontalInput) * movementSpeed * runningModifier; movementDirection = transform.TransformDirection(new Vector3(0f, movementDirection.y, actualSpeed)); }
// Update is called once per frame public void Animate() { running = Input.GetAxis("Running"); float runningModifier = runningHandler.GetIsRunningModifier(running); inputY = Input.GetAxis("Vertical") * runningModifier; inputX = Input.GetAxis("Horizontal") * runningModifier; bool isWalking = inputY != 0f || inputX != 0f; animator.SetFloat("InputX", inputX); animator.SetFloat("InputY", inputY); HandleJumping(isWalking); animator.SetBool("IsGrounded", controller.isGrounded); animator.SetBool("IsWalking", isWalking); }