Making bool true on GetKeyDown and false once animation is done

hey i was wondering how i could get my “Slide” animation to start on DownArrow and stop after the animation is done. I was thinking of adding a delay, but i have another running animation always running when grounded so Thread.sleep won’t work. ps. i’m new to unity and scripting so please go into detail.

Vector3 velocity = Vector3.zero;
public float JumpForce;
public float forwardSpeed;
private Rigidbody2D myRigidbody;
public bool Slide;
public bool Grounded;
public LayerMask whatIsGround;
public Transform GroundCheck;
public float GroundCheckRadius;

private Animator MyAnimator;


// Use this for initialization
void Start()
{

	myRigidbody = GetComponent<Rigidbody2D>();
	
	MyAnimator = GetComponent<Animator> ();
}

// Do Graphic & Input updates here
void Update()
{
	Grounded = Physics2D.OverlapCircle (GroundCheck.position, GroundCheckRadius, whatIsGround);
	
	myRigidbody.velocity = new Vector2 (forwardSpeed, myRigidbody.velocity.y);
	
	if (Input.GetKeyDown (KeyCode.UpArrow) || Input.GetMouseButtonDown (0)) {
		if (Grounded) {
			myRigidbody.velocity = new Vector2 (myRigidbody.velocity.x, JumpForce);
		}
	}

	MyAnimator.SetBool ("Grounded", Grounded);

	if (Input.GetKeyDown (KeyCode.DownArrow) || Input.GetMouseButtonDown (1)) 
	{
		if (Grounded) {

		}

	}

}

Ok. So to make what I’ve suggested you can add a simple public method to a script you want to switch bool in.

public void SwitchMyBool()
{
    myBool = false; //or true, or whatever you need here to be done
}

And after that you can call this method from animation as it is described in Using Animation Events page of Manual.

Will it work for you?

You can get the current animator state, and access the normalized time variable to tell how far along the state is. (0 being the start, 1 being the end.) bear in mind that a transition may prevent a state from reaching 1, so you may have to check for something close to the end, like .95.