Hello everyone
I am having problems with this. I want to activate a boolean variable when a variable reaches a certain frame, and set it to false again after 1 second (or 0.5, something like that). But I’m having problems with yield WaitForSeconds() because not always the variable triggers. I did something like this, but the script doesnt activate the variable at the same moment everytime and it doesn’t even activate sometimes (In javaScript):
If(Input.GetButtonDown("Fire1")){
yield WaitForSeconds(0.16); //0.16 it's moreless the time I've calculated
attacking = true;
yield WaitForSeconds(0.5);
attacking = false;
}
What can I do?
You can get a frame from an animation as animations have no frames, only animation time.
If you want to change something on an explicit frame, the way to go are animation events that you can hook up to fire at a specific frame 
I needed to get the frame number to reference an array of positions on the animated sprite based off the animation frame.
It’s worth noting that in the vast majority of cases, @Dreamora 's answer is sufficient.
For those who really, really need the current frame, here’s a line of code that’ll do that!
animationIndex = ((int)(mAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime * (mNumAnimationFrames))) % mNumAnimationFrames;
I had to do the modulo calculation at the end because for some reason normalizedTime was not returning a normalized value, and kept incrementing my index indefinitely.