Play full animation

How can i play full animation? Actually with this code when i left click, the animation in the animator last 1 second and it doesn’t complete the full shooting animation.

public class PlayerMov : MonoBehaviour {
public Animator anim;
public Rigidbody2D Bullet;

// Use this for initialization
void Start () {
	anim = gameObject.GetComponent<Animator> ();
}

// Update is called once per frame
void Update () {
	anim.SetFloat ("pSpeed", Mathf.Abs (Input.GetAxis ("Horizontal")));
	Vector3 newScale = transform.localScale;
	if (Input.GetKey ("a")) {
		newScale.x = 5.5f;
		transform.localScale = newScale;
	} else if (Input.GetKey ("d")) {
		newScale.x = -5.5f;
		transform.localScale = newScale;
	} else {	
		if (Input.GetButtonDown ("Fire1")) {
			anim.SetBool("isShooting", true);
			Instantiate(Bullet);
		} else {
			anim.SetBool("isShooting", false);
		}
	}
}

}

And how i can play an animation from the code? I’ve tryed animation.Play(“AnimationName”) but it doesn’t work…

Check out our Learn section on how to fully animate. Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn