- Home /
Weird frame numbers in imported animations
I'm currently importing a simple 2 bones animation from Blender into Unity and I found a weird behaviour occourring.
As can be seen in the images in Blender I'm using a frame rate of 30 fps with a 60 frames (1 to 60) animation giving a length of 2 seconds. In Unity the same clip is imported with frames going from 0 to 59 (why is that?) still with 30 fps but a lenght of 1.967, this doesn't add up.
Am I missing something in the import settings or is this behaviour intended?
Answer by theANMATOR2b · Apr 10, 2017 at 01:05 PM
Is the last animated keyframe of the bones in the blender file on frame 59? In Max the fbx export can default to the last frame where the last animated keyframe sits on the timeline.
To fix the artist can duplicate the keyframes on frame 59 and place them on frame 60.
Answer by AndreaBrag · Apr 10, 2017 at 03:07 PM
A friend of mine suggested that Unity might need to interpolate between the keyframes in order to create the animation frame (does it sound crazy?), so to make a 60 frame animation (meaning that if played at 30 fps it lasts 2 seconds) a 61st keyframe is needed in Blender.
That worked and I have now a 0 to 60 frame in Unity lasting 2 seconds at 30 fps. A official statement would be usefull anyway.
3D $$anonymous$$ax is similar in respect to frame numbers. The timeline begins at frame zero, so to get a 2 second clip, animation keyframes will go up to frame 59 when animating at 30fps.
Unity does interpolate between keyframes but that has no effect on duration of the animation afaik. I'm not an official Unity person - and probably shouldn't expect an official statement in the 'Answers' section. The documentation is 'official'.
Unfortunately the docs are lacking, or at least missing this information.
I still find weird that a animation going from 0 to 59 last ~1.9 seconds at 30 fps ins$$anonymous$$d of 2. Since you need at least 2 point to interpolate one can imagine that Unity uses those 60 keyframes in pairs (meaning 59 couples and 59/30 is equals to 1.96666... exactly the length that Unity shows) so adding one more keyframe result in 60 2-points pairs.
I don't know if I explained my self, I can try to clarify if needed.
Answer by Kamil1064 · Apr 10, 2017 at 05:31 PM
Hi @AndreaBrag, everything is ok, that may look weird but your first keyframe in blender is on frame 1, and last on frame 60 which mean your animation is 59 frames length. That's no matter which frame you set up in blender's timeline on start and end. Unity always takes from first to last keyframe: You may see an issue because first part of your animation is 14 frames length, rest are 15, but that depends what kind your animation is, maybe you want it.
There's still something that maybe I can't grasp. I get that left-shifting a 1-60 block is equal to a 0-59, but the total length shouldn't still be 60?
What i picture is a array of 60 elements (being the keyframes) at index 0 is the 1st key and at index 59 is the 60th, meaning a length of 60, while, as seen in the inspector, the length of this "array" is 59 since 59/30 give the clip length showed (1.967 seconds).