If an specifc animation is playing dont let other animations play.

I have a gun with an shooting animation and a reload animation, and a raycast script with a reload function.

  • Raycastscript is attached to MainCamera
  • Animations is attahed to the gun
  • The gun as a childobject to MainCamera

Reload function:

    function Reload(){
    if (clips > 0) {
    transform.FindChild("AUG").animation.Play("reload", PlayMode.StopAll);
    yield WaitForSeconds(2);
    bulletsLeft = 30;
    bulletsPerClip = 30;

The reload animation will play when the clip is empty, but if i try to shoot again the reload animation freezes, the freezing is not the problem, the thing that i can actually shoot while the reload animation is playing is bugging me.

In short

I want to disable the shooting animation when the reload animation is playing.

If anything was confusing please tell me xD

Thanks in advance

Written from my phone . But that’s how I do it , and it should work in your case too.

if  (!animation.IsPlaying("reloading"))