How to refresh animation state in unity to know what animation is playing

Viewed 234

Ok so, I did this:

print(Anim.GetCurrentAnimatorStateInfo(0).shortNameHash);

When I play an animation like so

Anim.Play("AnimationName"); 

The value printed changes and then stays the same and doesn't change back to the default animation. I also tried with the following:

if (Anim.GetCurrentAnimatorStateInfo(0).IsName("FireAnimation"))

I want to be able to get a constant update on the current animation that is playing. If you have any method that doesn't involve using a clock please do help.

1 Answers

I realized the best way to do this is to use the animation controller and change varialbes using SetBool(); and SetFloat(); etc.

Related