- Home /
how to find out how many seconds into and animation that is playing
Is there a way to reference this? I want to know because I want to have an if statement based on it.
ex: if(secondsIntoAnimation > 5) //do this
Answer by AurimasBlazulionis · Oct 28, 2016 at 09:29 PM
You could use something like this. Alternatively, you can store Time.time to a variable when you play the animation. And check it using if (Time.time - animationStartTime >= 5).
Answer by Naphier · Oct 29, 2016 at 04:23 AM
You may, instead want to look at animation trigger events, In the Animation window for the clip they are the little flag button (looks like a little stick with a + next to it), they can call methods on component attached to the same game object as the animator holding that clip. Usually a better option than trying to time it all out, especially since animations can start late, end early, etc.
Your answer