- Home /
Is there a function that will return the current frame of an animation?
I want to be able to freeze my animation at a particular frame if the player is shooting rapidly. Something like this:
if (timeBetweenShots < 0.3f && timeBetweenShots > 0.0f && animator.GetCurrentFrame() == 20)
{
animator.enabled = false;
}
I see there is a animator.GetCurrentAnimationClipState() but that doesn't look like what I need, unless I'm mistaken.
Answer by Owen-Reynolds · May 05, 2014 at 02:28 AM
Unity doesn't think of animations in frames. Use either time
or normalizedTime
. Time is in seconds, normalizedTime is always a 0-1 percent (0.5 is half-way done.)
Say you want frame 6 out of 24. That's normalizedTime 0.25. I think it uses 60 frames == 1 second, so would also be time=0.1.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Animation doesn't go back to idle in unity 1 Answer
control animation using animation control class 1 Answer
Distribute terrain in zones 3 Answers
Anisprite animation from OnTriggerEnter 0 Answers