Trying to check what anim clip is currently running on object

I have an object with several animations attached to it in the animator. I’m setting up the flow, and things are going good, but I need set a variable based on what animation is playing, or a way to tell what one I’m in.

thought this was the way to go… but maybe not?:
(In my class)

private Animator anim;

private AnimationInfo animInfo;

anim = GetComponent();

Then I thought I could do this:

animInfo = anim.GetCurrentAnimationClipState(0);

if(animInfo.clip == “spin”)

But I get an error on the GetCurrentAnimationClipState because it’s an AnimationInfo and not just AnimationInfo

Maybe I’m doing it all wrong? Anyone have a suggestion for a few lines that will get me the clip name that’s running that I can check against?

thanks in advance!
-B

Mecanim can blend animations on a layer – for example, running forward + turning to create a running turn. So multiple animations can be playing at the same time.

If you absolutely know that only one animation is playing, you can just use AnimationInfo[0]. But it would probably be better to iterate through the entire return value.

If you want the animator state, see: Getting a list of mecanim states in Animator - Unity Answers