I'm using the newest version of Unity. I have a turn based RPG type of game so everything is very sequential. The actor jumps in front of another actor, plays his melee attack animation, then jumps back. Currently I use events on the animation to tell when the attack animation is complete. The 2 side effects of doing it this way are:
I have to go into each animation and make an event at the end of them. It would be ideal to NOT have to do this. It would seem I should be able to just check in code if a certain animation is finished playing.
The control flow of my attack code becomes awkward. My attack method is a coroutine so I can read it very sequentially and it makes sense. Having this event to tell when the animation is complete ruins that flow. I have to basically make a bool variable and inside my finished event set it, and in my attack function do a while loop after I play the animation checking for that bool variable to change and yielding out until it does. Requiring this event ruins the logical flow of attacks. If I have many animations for whatever reason things get messier.
I noticed the Animator component doesn't have an isPlaying() like some other answers suggested. I think those answers were for older version of unity and older just playing animation clips not using the new Animator component.
There must be a better way to do this.