Integer changes too quickly to play animation

Here is the related code to go with the problem

GunAnimator.SetInteger (“Shoot”, 1);
nextTimeToFire = Time.time + 1f/fireRate;
Shoot();
GunAnimator.SetInteger (“Shoot”, 0);

Without the second .SetInteger the animation plays, but the moment I add the second .SetInteger the animation no longer plays.

It can be useful to refer to the order of execution with Unity scripts:

From that graph you can see that all your scripts run, and then when they’re done, the animation is processed.

This means only the final value of “Shoot” is operated upon, which explains your problem above.

I recommend instead using a Trigger type instead of an integer, as I believe that clears itself.