How to play the animation completely on mouse click

Hi! We’re having some troubles with the animation sistem. Basically, we want to make the attack animation play on mouse click, but it just does the first frame of the animation, while we want the animation to complete when you press the mouse button.

This is the code we are using: `void Update () {

	if (Input.GetKeyDown (KeyCode.Mouse0)) 
		animator.SetBool ("BaseAttack1", true);
    else 
		animator.SetBool ("BaseAttack1", false);
	
}`

but it just does the first frame of the animation

Because that’s what you’re telling Unity to do.
Update() runs every frame. So, basically what you’re doing here is playing animation at mouse click and then stopping it the in the next frame.

Input.GetKeyDown (KeyCode.Mouse0)) will return true at Mouse click, so the bool will be set to true and animation will start. But, user stopped pressing mouse and in the next frame you are setting the bool to false, causing it to stop the Animation.

What you should do is remove the else part and in the Animator Window, select the transition and check “Has Exit Time”.