I have an animation that’s around 4.5 seconds long.
When I use that animation with mecanim (Animator on GameObject, Controller, etc. all set up) the animation only plays for 1 second.
The inspector shows the right duration, but when i play the animation in-game it’s just 1 sec.
Yes, the preview is 1 second as well.
If i click the animation clip asset it says 4.5 in the “length”-label.
If I open the animation’s .anim file with a text editor, there is a tag m_stoptime which is set to 1. If i change that, the animation works.
We recorded the animation via code from the gyroscope. Is there anything to keep in mind?
We created an AnimationCurve, then used AddKey to add key frames, created an AnimationClip and set the curve via SetCurve. Finally we set a name and saved the AnimationClip with AssetDatabase.CreateAsset.
Oh you did create all your clips by script.
You need to fill up all the mecanim clip data too.
Depending on which version you are using either you will need to use serialized object to setup your clip or use
AnimationClipSettings AnimationUtility.GetAnimationClipSettings(AnimationClip clip)
You are looking for those two properties.
m_AnimationClipSettings.m_StartTime
m_AnimationClipSettings.m_StopTime
@erana79 , can you log a bug with your project and some repro?
We are working on a fix but we would like to test with your specific use case to be a sure that we fix the same bug.
@Mecanim-Dev Is this the problem that I can’t see more than one second in the inspector view (see screenshot). I’m using 5.1.1f1 and want to add events to my animation. You can see that the animations length is 2.875, but in the event area, I can only insert events to the first second.
Ah, I see. Is this intended? I can’t see an use case where this would be more useful instead of the real animation time. It’s harder to calculate which percentage you have to use, but it’s easy to select the frame where you want the event to be. Do I miss something here?
In the animation window, I can also set up the events to the specific frame when the event should be triggered, so why not in the import settings in the inspector.