x


How to set the duration of a looping animation from the inspector?

Hopefully this is just a newbie question, but I can't seem to see where Unity defines the duration of an animation. It always seems to be a little way after the last keyframe, and rather infuriatingly, even just moving the playhead to a position after the last keyframe extends the animation even further.

I'm trying to make a simple looping spinning cube - nothing difficult. I've set my Wrap Mode to Loop. I've added a curve for Rotation.x, I've set up only two keyframes, f0 = 0° and f60 = 90°. Now this is what I see when I zoom out on my Animation inspector:

alt text

Now, can anyone explain

1) where did Unity decide to set the length of my loop to (approx) 58:00 and how do I change that? You'll see there are no other keyframes on any of the timeline objects

2) why, when I move my playhead further right than 58:00 (ish), that extended flat line goes even further - but I can never get it to reduce the length of the animation? Argh!

3) how can I reduce the length of my animation to be 1:00 (i.e., 60 frames) so that my rotating cube looks seamless?

I'm sure I'm overlooking some minor detail. Please enlighten me!

more ▼

asked May 09 '12 at 02:03 PM

adrianward gravatar image

adrianward
30 1 1 2

I've just spotted this almost identical question:

http://answers.unity3d.com/questions/240937/why-is-unity-adding-extra-frames-to-animation.html

For the record, I am also on Mac OS X (10.7.3, 11D50b), but running Unity 3.5.1f2, and I consider this to be a Unity bug.

May 09 '12 at 05:10 PM adrianward
(comments are locked)
10|3000 characters needed characters left

5 answers: sort voted first

Had the same problem, found this in the support forums: http://forum.unity3d.com/threads/131340-Reduce-animationclip-length/page2 the script on that page fixes the animation. so thanks to alstonc99, Helmut Duregger and Robin1508, for making these scripts. I used the last version (on page 2, by Robin1508), and it worked like a charm.

more ▼

answered Jul 27 '12 at 09:22 PM

Steven 1 gravatar image

Steven 1
377 28 36 49

(comments are locked)
10|3000 characters needed characters left

I'm getting this bug too. I see that the previous answers don't understand that you've already set a keyframe on your last frame. Your animation is naturally starting at 0:00, and ending at 1:00, however Unity is extending the clip to 58:00 for seemingly no reason. You've got two keys, that's obvious, but Unity's acting like there's 3.

This is a very frustrating bug and I would also like a solution.

more ▼

answered May 24 '12 at 09:39 PM

wowen gravatar image

wowen
1

so you'd like to vote up the question and maybe add a comment to it. not such an invalid answer. bashed

Oct 18 '12 at 01:58 PM Cawas
(comments are locked)
10|3000 characters needed characters left

If by any chance you're importing from an FBX and using Unity 4, you can edit the FBX Import Settings / Animations (look at the Inspector when you select the FBX), add a clip and set the length there. This actually works on Unity 3 as well, but I can't see the exact steps in here - I recall it's very similar though. ;-)

more ▼

answered Oct 18 '12 at 02:05 PM

Cawas gravatar image

Cawas
1.3k 31 38 54

(comments are locked)
10|3000 characters needed characters left

Set a keyframe for the last frame and set to loop. You have no last keyframe.

more ▼

answered May 09 '12 at 06:14 PM

mrldev gravatar image

mrldev
1 2

Sorry, that doesn't make sense.

1) I do have a last keyframe, the one I defined at 1:00 (frame 60). That's the last frame I want in my animation.

2) If I try to create a keyframe at the actual end of the current animation (let's say around 58:00), so be it. But that's not how long I want it to be! If I then either drag that keyframe leftwards to make it earlier, or delete it, the keyframe moves but the animation still stays at it's long length.

May 10 '12 at 09:51 AM adrianward
(comments are locked)
10|3000 characters needed characters left

I believe you have to set a keyframe at the last frame of your animation and the length is automatically picked up by first and last frames.. Not totally sure but I recall thinking the same thing and then finding the animation was the correct length after puzzling it over.

more ▼

answered May 09 '12 at 06:14 PM

mrldev gravatar image

mrldev
1 2

Thanks for trying but it's not working for me. Please see my comment to your first answer.

May 10 '12 at 09:52 AM adrianward

sometimes I wonder why people bother registering and typing stuff if they don't follow it up nor care if it helped or not... then I get back to getting a life.

Oct 18 '12 at 02:00 PM Cawas
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3807
x50
x38
x24
x15

asked: May 09 '12 at 02:03 PM

Seen: 1784 times

Last Updated: Oct 18 '12 at 02:05 PM