How do i check if an animation is playing?

Howdy, i’m trying to make a recoil animation for a weapon in my game and i need to animation to start immediately upon firing. right now it waits for the animation to finish before it loops again. here’s what i have:

if (GunModel.GetComponent<Animator>().IsPlaying("PistolRecoil") == true)
        {
            GunModel.GetComponent<Animator>().Rewind("PistolRecoil");
        }
        else
        {
            GunModel.GetComponent<Animator>().Play("PistolRecoil");
        }

Novice programmer for me is an overstatement but looking at the unity documentation i don’t see why this should be working? im getting a compiler error that says “The animator does not contain a definition for ‘IsPlaying’ (or ‘Rewind’)” although the documentation says otherwise? Any help is greatly appreciated

Where does it say Animator has an IsPlaying and Rewind function?
It is the Animation that has IsPlaying, not Animator. You’re confusing the two.

FYI: To check if an Animator is in some state named “PistolRecoil”, presumablly playing a PistolRecoil animation:

var isPlayingAnimation = animator.GetCurrentAnimatorStateInfo (0).IsName ("PistolRecoil");