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);
}