Determine in which frame is an Animation currently

Hi, the problem that I have encountered is that I want to know in what frame an animation is, since depending on it, when an object is killed a different animation should play so it makes sense. For example, if the enemy is looking up, when its killed it plays a different animation than when he is looking down. I’ve tried with CurrentAnimatorStateInfo but can’t achieve the results I want. I´ve also tried a code found somewhere else, in which it recommends using this:

ratio = GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime / GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length;

frame = ratio * (framesInAnimation);

in order to determine in which frame the animation is, but still I can’t determine the current frame of an animation, any other ideas on how to approach this problem?

What I want to achieve is something like this:

public void Death()
{

if(frame == 1)
{
     animator.SetBool("Death1", true);
}
if(frame == 2)
{
     animator.SetBool("Death2", true);
}
etc...
}

Can you enter in an event trigger in the animation clips timeline? You can choose the frames you want for the events. Then you can specify the method to check which death sequence you should play.

http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html

So you have a long animation during which the enemy is looking down, then up, etc. Something like that?

If so then the best way to do what you want to do is I believe to have 2 (or more) animations instead of 1. You should have 1 animation for each status of your enemy.
Assuming your enemy is either looking down or up: you can create a first animation “enemy look down” with the first half of your sprites, and then “enemy look up” for the second half of your sprites. Then in your animator you make them loop (when “enemy look down” is finished it goes immediately to “enemy look up”, when “enemy look up” is finished it goes immediately to “enemy look down”). In the game you won’t be able to tell that there are actually 2 animations looping. Thanks to this you can then create a transition between each animation to your appropriate death animation (“look down death”, “look up death” for example). When your “Death” boolean is true (no need for Death1 or Death2) it will trigger the suitable animation depending on the origin state.

I hope that helps.