2D muzzle flash is stuck on visible frame upon releasing fire button

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Miro

Everytime I hold my automatic gun fire button the animation loop starts and when I let go of the button the visible frame of the muzzle flash gets stuck on when I’m not firing. Do I need a timer node or is it just in the code?

:bust_in_silhouette: Reply From: Andrea

i’m not sure because you havent provide any piece of your code, but i assume when you release the fire button you are stopping the Animation player that was running on a loop, using $AnimationPlayer.stop() which means the animation parameter will freeze in the last value they had (if the last frame was a muzzle flash, you’ll see the muzzle flash).
if that’s the case you can simply reset the parameter when the animation player ends (either by code, or by using another animation for “reset”)