- Home /
Animation Time?
I animated a character and I'm ready to import it into Unity. However, Unity runs animations in units of frames, and I need animations to play and loop in units of TIME. Is it possible to set, for example, 20 frames of animation to be equivalent to one second? If so, how? I'm new to Unity, so I would appreciate it if any help were n00b-friendly. Thanks!
I don't know if that helps but before playing an animation you could set the speed with animation["TestAnimation"].speed = ...
Answer by Owen-Reynolds · Jun 06, 2012 at 06:15 PM
Unity runs animations in either seconds or a 0-1 percent. Look up AnimationState
: length
and (current)`time` are in seconds. normalizedTime
is the percent. The animation docs make a point of saying the (key)frames are turned into a continuous time curve, and then the actual frames are sort of ignored.
Now, on import, Unity "guesses" the animation length based on the framerate you were using. It might assume your 20-frame animation should take 2/3 sec. But (as ETS wrote,) you can easily change playback speed to 0.6666, to take 1 sec. Turns out length
is locked at the starting guess, so you can't just change it to 1 sec.
For fun, say an animation plays over 3 seconds (doesn't matter how many frames it was, as long as you adjust speed.) If you want to jump to the 2 second mark, which is 2/3's of the way, use the percent method: animation["A"].normalizedTime=2.0/3.0;
. No frames needed.
[Note to self: hit refresh before starting a response]
Answer by Paulius-Liekis · Jun 06, 2012 at 05:29 PM
I'm not entirely sure what you mean by "Unity runs animations in units of frames". Unity actually iterates animation time in seconds, i.e. AnimationState.time is in seconds. For imported models frames-per-second number comes from the file, so look for that setting in your animation tool.
Your answer
Follow this Question
Related Questions
How to Control the Animation using Slider ? 3 Answers
Animation Control by frame (use Animation.State.time) 1 Answer
Fast-forwarding an animation to its last frame 2 Answers
how to make my component disabled after an animation 1 Answer
Frames per second not showing,Animation frames not showing 0 Answers