// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // Update from player if (__player != null) { JumpBehaviour jumpBehaviour = __player.GetComponent <JumpBehaviour>(); PlayerBehaviour playerBehaviour = __player.GetComponent <PlayerBehaviour>(); Rigidbody2D rb2D = __player.GetComponent <Rigidbody2D>(); SpriteRenderer sr = __player.GetComponent <SpriteRenderer>(); Vector2 input = jumpBehaviour.getInput(); if (jumpBehaviour && playerBehaviour && rb2D) { hasYMotion = rb2D.velocity.y != 0f; //hasXMotion = rb2D.velocity.x != 0f; hasXMotion = input.x != 0; isMoving = hasXMotion || hasYMotion; // check walking isWalking = (jumpBehaviour.IsGrounded()) && hasXMotion && !hasYMotion; // check running isRunning = (jumpBehaviour.IsGrounded()) && hasXMotion && !hasYMotion && (playerBehaviour.PlayerSpeed >= playerBehaviour.PlayerMaxSpeed); isJumping = Input.GetKey(KeyCode.UpArrow); // check in air isInAir = (!jumpBehaviour.IsGrounded()) && !(jumpBehaviour.AskedForJump) && hasYMotion; // Update animator animator.SetBool(paramIsJumping, isJumping); animator.SetBool(paramIsWalking, isWalking); animator.SetBool(paramIsRunning, isRunning); animator.SetBool(paramIsInAir, isInAir); animator.SetBool(paramDoubleJump, jumpBehaviour.CanDoubleJump); // Flip if needed if (__spriteIsFacingRight && jumpBehaviour.getInput().x < 0) { flip(sr); } else if ((!__spriteIsFacingRight) && jumpBehaviour.getInput().x > 0) { flip(sr); } } } }