Q:

Unity: Shooter 2D-Character animation only runs once

I wanted my animation to play whenever my character shoots the gun but currently the animation runs only when it fires the first time and not the others. I have the impression that it will be something very simple in the code but I have been around here and still have not found a solution. Can someone give me a hint, please?
Here is the animation part in the code:
private Animator myAnimator;
private bool isFire;
private string FireAnimHash = "isFire";

void Awake()
{
    spriteRend = GetComponent<SpriteRenderer>();
}

void Start()
{
    myAnimator = GetComponent<Animator>();
    myAnimator.enabled =true;
    myAnimator.SetBool (FireAnimHash ,isFire);
}

private void Update()
{
    AimArmAtMouse();

    if (Input.GetButtonDown("Fire1"))
    {
        isFire = true;
        myAnimator.SetBool (FireAnimHash ,isFire);
    }
}

A:

Actually, you use Triggers, not bools, when animating these types of animations, which become true and then false.
Copy the below script and change the variable type to trigger from bool in animator tab in unity.
It should work.    
 private Animator myAnimator;
 private string FireAnimHash = "isFire";

 void Awake()
 {
     spriteRend = GetComponent<SpriteRenderer>();
 }

 void Start()
 {
    myAnimator = GetComponent<Animator>();
    myAnimator.enabled = true;
 }

 private void Update()
 {
     AimArmAtMouse();

     if (Input.GetButtonDown("Fire1"))
     {
       myAnimator.SetTrigger(FireAnimHash);
     }
 }

