title: Juggled player animation on the slopes in Unity
body: <p>I have another issue with my animator in 2D.
  Currently i have only few slopes in game, but it annoys me, because i don't know how to make animation work properly on them. This is one example:</p>
  <p><a href="https://i.stack.imgur.com/KkNJG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KkNJG.png" alt="enter image description here" /></a></p>
  <p>As you can see, there is little slope. Now how my Animator looks like:</p>
  <p><a href="https://i.stack.imgur.com/0aYEk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0aYEk.png" alt="enter image description here" /></a></p>
  <p>The code now looks like it:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.InputSystem;
  using System;
  
  public class PlayerMovementScript : MonoBehaviour
  {
      [SerializeField] float runSpeed;
      [SerializeField] float jumpSpeed;
      [SerializeField] float climbSpeed;
  
      Vector2 moveInput;
      Rigidbody2D playerRigidbody;
      Animator playerAnimator;
      CapsuleCollider2D playerCapsuleCollider;
      float gravityScaleAtStart;
  
      void Start()
      {
          playerRigidbody = GetComponent&lt;Rigidbody2D&gt;();
          playerAnimator = GetComponent&lt;Animator&gt;();
          playerCapsuleCollider = GetComponent&lt;CapsuleCollider2D&gt;();
          gravityScaleAtStart = playerRigidbody.gravityScale;
  
      }
      void Update()
      {
          Run();
          FlipSprite();
          ClimbLadder();
          Falling();
      }
  
      void OnMove(InputValue value)
      {
          moveInput = value.Get&lt;Vector2&gt;();
          Debug.Log(moveInput);
      }
  
      void OnJump(InputValue value)
      {
          if (!playerCapsuleCollider.IsTouchingLayers(LayerMask.GetMask(&quot;Ground&quot;))) { return; }
  
          if (value.isPressed)
          {
              playerRigidbody.velocity += new Vector2(0f, jumpSpeed);
          }
      }
  
      void Run()
      {
          Vector2 runVelocity = new Vector2(moveInput.x * runSpeed, playerRigidbody.velocity.y);
          playerRigidbody.velocity = runVelocity;
  
          bool playerHasHorizontalSpeed = Math.Abs(playerRigidbody.velocity.x) &gt; Mathf.Epsilon;
  
          if (playerCapsuleCollider.IsTouchingLayers(LayerMask.GetMask(&quot;Ground&quot;)))
          {
              playerAnimator.SetBool(&quot;isRunning&quot;, playerHasHorizontalSpeed);
          } else
          {
              playerAnimator.SetBool(&quot;isRunning&quot;, false);
          }
      }
  
      void FlipSprite()
      {
          bool playerHasHorizontalSpeed = Math.Abs(playerRigidbody.velocity.x) &gt; Mathf.Epsilon;
          if (playerHasHorizontalSpeed)
          {
              transform.localScale = new Vector2(Mathf.Sign(playerRigidbody.velocity.x), 1f);
          }
      }
  
      void ClimbLadder()
      {
          if (!playerCapsuleCollider.IsTouchingLayers(LayerMask.GetMask(&quot;Climb&quot;))) {
              playerRigidbody.gravityScale = gravityScaleAtStart;
              playerAnimator.SetBool(&quot;isClimbing&quot;, false);
              playerAnimator.SetBool(&quot;isClimbingIdle&quot;, false);
              return;
          }
  
          Vector2 climbVelocity = new Vector2(playerRigidbody.velocity.x, moveInput.y * climbSpeed);
          playerRigidbody.velocity = climbVelocity;
          playerRigidbody.gravityScale = 0;
  
          bool playerHasVerticalSpeed = Math.Abs(playerRigidbody.velocity.y) &gt; Mathf.Epsilon;
          playerAnimator.SetBool(&quot;isClimbing&quot;, playerHasVerticalSpeed);
          playerAnimator.SetBool(&quot;isClimbingIdle&quot;, !playerHasVerticalSpeed);
      }
  
      void Falling()
      {
          if (
              playerCapsuleCollider.IsTouchingLayers(LayerMask.GetMask(&quot;Climb&quot;))
              || playerCapsuleCollider.IsTouchingLayers(LayerMask.GetMask(&quot;Ground&quot;))
          ) {
              playerAnimator.SetBool(&quot;isJumping&quot;, false);
              playerAnimator.SetBool(&quot;isLanding&quot;, false);
              return;
          }
  
          bool playerHasVerticalSpeed = Math.Abs(playerRigidbody.velocity.y) &gt; Mathf.Epsilon;
          if (playerRigidbody.velocity.y &gt;= 0)
          {
              playerAnimator.SetBool(&quot;isJumping&quot;, playerHasVerticalSpeed);
              playerAnimator.SetBool(&quot;isLanding&quot;, false);
          } else
          {
              playerAnimator.SetBool(&quot;isJumping&quot;, false);
              playerAnimator.SetBool(&quot;isLanding&quot;, playerHasVerticalSpeed); 
          }   
      }
  }
  </code></pre>
  <p>If my player went on slope, Animator shows my animations switch quickly between Run, Jump and Land. How to fix it to save correct jump animation?</p>