Animation length (596183)

Hey all! I have a quick question: I made a simple 2D sprite animation with unity. The sample frame rate is 60 and the animation lasts for 0:28 in the “Animation” window. On the other hand, the inspector says that the exit time and length of the animatio is 0.48. What is going on? How can the length be 0.48 when I explicitly made it 0:28 long?

Thank you for your time.

EDIT: Bonus question: is GetCurrentAnimatorClipInfo().length accurate? I have seen some posts about it not being that good.

Which version of Unity do you have? We did fix a bug in 5.1 I think related to animation length.

GetCurrentAnimatorClipInfo().length this value come from the animationClip directly
http://docs.unity3d.com/ScriptReference/AnimationClip-length.html
Both value should be the same

Just updated to 5.1 and the length difference remains. This screenshot should ilustrate my point:

Is it a bug?

ah no this is expected, the animation window timeline is not in second but in frame
and the animation clip lenght is in second

So 0:28 is the frame number, to get the time simpy divide by the sample rate
0.28/60 = ~0.48

Ok, supposing that the animation lasts 0.48 seconds, I am still getting a wired valu out of GetCurrentAnimatorClipInfo().length.

Animator.GetCurrentAnimatorClipInfo(0).Length returns 1.

When are you calling this function exactly? The result of this function is only valid while the editor is in play mode and the animator been evaluated by the engine.

Hello!

I’m creating an Augmented reality animation video in unity and I ran in some problems.
I have created some characters in Cinema 4d, And I rigged them. Importing the characters was not a problem.
But then I start animating the arms, leg, head and torso with a lot of keyframes still no problems.
But then I was building the set for the video and I stopped worrking on the characters. Importing the set was also not a problem for unity. After working on the set I worked on the characters again but Unity had problems to import the charachters now. I tried everything, I reimport the characters scene, Saving the character in a new file, made sure all textures were linked etc, Then I delete the keyframes and saved it in a new file, now unity didnt had any problems to import it. But when I copy the keyframes from the old file in the new files timeline, unity gives problems again, it looks like unity doesnt refresh the file because if i look in the assets folder in unity the scene is still the scene and not an error paper image. Does anyone know whats going on? and how to import the character with the timeline in a proper way?

thanks Maurice

I am in play mode and I am doing the following with code:

avatarAnimator.Play ("Animation");
Debug.Log(avatarAnimator.GetCurrentAnimatorClipInfo(0).Length);

The result is always a 1 no matter what animation I play.

You cannot call Play and the line after call GetCurrentAnimatorClipInfo, the animator need at least one tick to process your request.

Either you print Debug.Log in LateUpdate or you wait for the next update frame.