Loop Animations

Hello,

I am trying to import some animations for a character from Maya to Unity. Some animations are 60 frames long, others are longer. The idea is that, for example, for a walking cycle, I have the 1-60 frame animation, and then another animation (lets say “Running”) goes from frame 61-120, and so on.

When I hit “play” in maya, with the time slider from 1-60, the animation looks fluid, without any jumps. But when I import to Unity, the animation has a small “jump” at the end of the loop.

Just as extra info, in the Import Settings in Unity, for the model, I have the “Split animation into multiple clips” enabled, and the clips named with the correct frame range. Also, all animations are controlled through script.

I hope someone could help me, please.

Nicolas.

–Oh one more thing. I also tried to “bake” keyframes in maya…I got the same issue.

You could try adjusting the frame ranges by one in different directions. It could be a difference between 1 and 0 indexing or a smoothing problem. If you can rearrange the keyframes in maya you could try making the start and end points of each loop longer than 1 frame.

Hello Yoggy,

Thank you for replying. I didn’t get the quoted part. I already tried to do the frame range but didn’t work. The problem apparently (in some loops) is that the beginning of the loop and the end of the loop don’t match (this happens ONLY in Unity).

Nicolas.

I made a small test, checking the position of the first frame and the last frame of a loop inside the Unity application (in the Animation Tab). Both are identical. Also, I enabled the “loop frame” in the Import Settings tab (which should solve any problem). But still, I have the same issue. Apparently, Unity creates a 3-frame animation after the end of the loop which distorts the animation. I have tried everything and I’m running out of ideas… Any suggestions will be appreciated!!!

Nicolas.

Yet another discovery. I counted the frames individually for each loop. In Maya, I got 60 frames for one animation, counting from the first keyframe of the loop, to the last keyframe of the corresponding loop. When checked in Unity, I opened the Animation Tab (command+6), and opened the same loop. I counted 61 frames!!! (labeled in red in the timeline). There appears to be one extra frame created by Unity!
I also did a test using a “frame counter” displayed as a GUI Text. I get the “frame error” some 10 frames before the end of the loop. This is very strange, and I haven’t been able to find any help in the Unity Documentation. I hope someone can help me out, please.

Nicolas

Ok, we came across something that looked the same. Hopefully it’s the same thing, since we found a solution / hack …

1: load your character into a prefab
2: open animation tab (F2 i htink)
3: set an animation as main
4: move timeline foreward and backwards to load the proper animation keys
5: scrub to the first frame, hit record, scrub to the final frame, hit record
6: select a new main animation, rinse, repeat

Re-importing or changing the import options will kill the changes.

If anyone from Otee could shed some light on why this would be happening, I’d be very interested :wink:

Jeff.

Ok, maybe not. After shutting down the Mac and restarting it, my animation problem returned … oh well, it was worth a try and it seemed to work for a short while at least :frowning:

Does this mean that you can’t loop animations from Maya without popping? :o

Hi guys. I ran into this problem with Offroad Velociraptor Safari.

The problem (as near as I could gather) is that the rate the animation plays is not the same as the rate the screen is drawing, so sometimes the character is between individual frames in your animation (so maybe he is on frame 24.5, 26.2, etc.). The trouble is when it can end up slightly beyond the boundary of your animation. Therefore, if you have dramatically different animation curves between frame 60 of your first animation and frame 1 of your second animation (61 on the slider), it can sort of overshoot for that fraction of a frame and think it is supposed to keep following the curve.

My solution was just to add some extra keyframes outside the bounds of the clip. For a 12-frame cycle, for instance, I would animate the cycle maybe +/- 6 frames (just however far apart your actual keys are) so there is a buffer between clips in a single file. For instance, 0-24 I would animate my 12-frame cycle (so 2 cycles) in Maya and then just set Unity to pull the animation out of the middle (6-18). Another solution is to use separate files for animations of course and just set their curves to repeat out of bounds.

Hope this helps!

Thanks, Adam, I’ll try this tomorrow when I get back to the office.

I appreciate it!

I’m not sure what the source of your pop could be, I’ve been looping animations from maya quite smoothly. I always tell Unity to bake IK and to NOT do keyframe reduction though, so that my curves are 100% accurate to their maya counterparts. I also never use unity’s “make loop frame” feature, instead making sure that my start and end frames in maya are identical. If any of this differs from how you have your import settings you might want to give my setup a try.

And while it may seem obvious, have you done a playblast in maya to see if the pop becomes visible? When merely playing back in the viewport in maya, depending on how speedy your computer is, maya will drop frames, which can have the illusion of smooth playback when in fact you have a pop that’s only visible when played back at maximum smoothness.

If none of this is helpful, I’d try doing a simple test, like a ball bouncing loop, and see if you still get pops with even something that simple.

Thanks, Mr. Animator :slight_smile:

I’ve just arrived at the office and once my 3d guy arrives I will pass on the info and we can try it again.

Ok, so we tried re-exporting our animation with extra keyframes at each end but it still popped at the end of the cycles.

Next try was to export all the animations separately, which worked fine. I remember someone (I think it was Joachim but not sure tbh) said that we should export all animations together in a single file, but I can’t for the life of me remember why that was …

Is there a cost of exporting animations as separate files?

Another question … Mr. Animator, are you using Maya on the PC or Mac? I mean, could this be another odd platform difference? We noticed that the scale seems to be different when you export from the PC than it is on the Mac, so I just wonder if this is another little ‘quirk’ of the cross-platform kind?

Thanks for the help. We’re going to just separate animations in to separate files, which isn’t ideal but it works and there’s so much other work to do that I don’t really want to spend any more time experimenting on it (add to that my poor 3d guy who is already starting to get grumpy about the slightly messed up pipeline, but not quite as grumpy as he got when we used Torque!).

As always, I totally appreciate the help :slight_smile:

That’s very odd, but at least you guys found a workaround. I’m working with maya 8.5 on a mac, opening and editing my maya files directly from my project assets folder, and letting unity auto-convert my files to FBX’s.