Having some animation trouble

So I have created a run animation and a jump animation and an idle animation that can all transition bewteen eachother. However, the jump animtion is giving me trouble. Whenever the animation is triggered, it plays several times and then reverts to the idle after a few loops. First of all, I don’t even know hows thats possible becase it is only supposed to revert to idle once you have been grounded again, so thats pretty weird. Aslo I dont want it to loop, just run once and then hold on the end frame until the animation is complete. Is there nayway to fix this?

Here is my code: (sorry this is my entire player controller, I mean you never know what might be relevant)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Sprites;

public class playerController : MonoBehaviour
{

//MOVEMENT
[Tooltip("The maximum horizontal movement speed in units per second.")]
public float speed = 8; // movenment speed for Luca

[Tooltip("The maximum vertical jump speed in units per second.")]
public float jumpspd = 12; // jumo height for Luca

private float moveInput;
private Rigidbody2D rb;


public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;

public static bool canVBeset;

//ANIMATION
public Animator anim;
bool canDash = true;
public bool grounded;
bool isRunning;
public SpriteRenderer ren;


//UNUSED AS OF NOW
public static float LucaHP;
public static float LucaSP;


//TODO: MOVE ONTO NEW SCRIPT


// Use this for initialization
void Start()
{

    canVBeset = true;

    anim = gameObject.GetComponent<Animator>();
    anim.SetBool("isRunning", false);
    anim.SetBool("dashing", false);
    anim.SetBool("isJumping", false);
   

    canDash = true;

    rb = GetComponent<Rigidbody2D>();
}

// Update is called once per frame

void Update()
{
    HandleDash();
    HandleFlip();
    HandleJump();
    anim.SetBool("isRunning", isRunning);

    if (Input.GetButton("Horizontal"))
    {
        isRunning = true;

    }
    else
    {
        isRunning = false;
    }
    

    if (grounded == true)
    {
        anim.SetBool("isJumping", false);
    }
    
}

void FixedUpdate()
{
    if (canDash == true && canVBeset == true)
    {
        playermove();
        
    }

}

void playermove()
{
    grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);

   
    float axixX = Input.GetAxis("Horizontal");
    //transform.Translate(new Vector2(axixX, 0) * Time.deltaTime * speed);
    

    rb.velocity = new Vector2(axixX * speed * Time.deltaTime, rb.velocity.y);
    

    
}

void HandleJump()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        if (grounded == true)
        {
            GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpspd);
            anim.SetBool("isJumping", true);
            grounded = false;

        }
    }

   
}

void HandleDash()
{
    if (Input.GetKeyDown(KeyCode.LeftShift))
    {
        StartCoroutine(dash());
    }
}

void HandleFlip()
{
    if (Input.GetKeyDown(KeyCode.A))
    {
        ren.flipX = true;
    }

    if (Input.GetKeyDown(KeyCode.D))
    {
        ren.flipX = false;
    }
}

IEnumerator dash()
{
    if (canDash == true)
    {
        
        canDash = false;
        anim.SetBool("dashing", true);
        if (ren.flipX == true)
    {
        GetComponent<Rigidbody2D>().velocity = new Vector2(-jumpspd , GetComponent<Rigidbody2D>().velocity.y);

    }
    else
    {

            GetComponent<Rigidbody2D>().velocity = new Vector2(jumpspd , GetComponent<Rigidbody2D>().velocity.y);

    }
    yield return new WaitForSeconds(0.2f);
    
        anim.SetBool("dashing", false);
        canDash = true;
    }
}

}

Go into the Project tab in unity and click on the animation file. Uncheck “Loop Mode.” This will stop the animation from looping. I don’t think the problem is with your code, try checking the Animator. Make sure “exit time” is set to false (unchecked) on the transitions.

Here’s an idea. Instead of having HandleJump(); in the Update function put the keydown there. I don’t use bools i use SetTrigger and this works for me because as the code runs from top down and sets the trigger to start the animation, resetting the trigger doesn’t affect the running of the animation once started. Maybe that is true for setting bools to true as well? so once the conditions are met to start the animation I revert the conditions so they don’t repeat the animation. But not sure if setting the two conditions to false will mess up the Vector 2 code - like if it will stop running once the conditions reversed. So…maybe back to using a coroutine to do that

 void Update(){
 if (Input.GetKeyDown(KeyCode.Space))
grounded = false;
 anim.SetBool("isJumping", true);
    HandleJump();
}
    }

     void HandleJump()
     {
             if (grounded == false)
             {
                 GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpspd);
                 grounded = true;
  anim.SetBool("isJumping", false);
             }
         }
        
     }