Saturday, February 23, 2019

Motion Builder and Unity Mecanim Retargeting




        Re-targeting and editing animations was going pretty well. It was nice to revisit Motion Builder. Everything was going fine in Motion Builder, until I baked my final animation from my control rig to the skeleton, and the character would be frozen on the last key frame he was on before baking. I don't know if this is a bug, but it can be a fatal error if you have spent hours to refine an animation, only to not be able to bake it back down to the skeleton and export it as an FBX.

        I took a break from MotionBuilder and hit the Unity documentation, learning how to re-target and edit animation clips in Unity. In the inspector, I learned how to retarget animations, make them looping, and edit the root transform. In order to zero out the position of the character, so that the character was moving in-place, at the origin, I had to edit the clip in the Animation editor. Imported animation clips are read-only by default, and there appears to be no way to unlock it. So, I had to create a copy of the mocap clips I wanted to use and edit the key frames of those.

        Unity documentation on looping animation clips in the engine:
https://docs.unity3d.com/540/Documentation/Manual/LoopingAnimationClips.html
https://docs.unity3d.com/Manual/LoopingAnimationClips.html

        This can be very useful, but is ideal for longer animation clips with more possibly matching parts. Otherwise, it can cause weird smooth "hicups" in the looping animation. For example, if you are trying to make a looping animation clip of someone walking or running, and the clip is not long enough, or does not have enough closely resembling parts, it can cause weird things to happen such as the feet sliding on the floor, or stuttering in the clip. Unity has nice tools to help create these looping animations very quickly, such as wire graphs. The wire graphs show if the two ends where you are cutting the clip short at will produce a seamlessly looping animation or not.

        In short, Unity offers the quickest, most efficient solution to re targeting and editing animations for the bare minimum of what one needs. However, if you want to do more, you will have to edit the animations manually in the Animation editor. Motion Builder, however, allows more precise control for editing animations, is more efficient because it allows the animator to use animation layers. Re-targeting in Motion Builder is more tedious, and so is creating looping animations, but you have more control.

Making read-only animations editable in Unity:
https://www.youtube.com/watch?v=cNnnaHqhks0

I still decided to fix my issue in Motion Builder since I may need to use it to create more precisely refined looping animation clips. The solution was very simple, don't delete the MoCap skeleton character until the animation is baked to the other character's skeleton, and the other character is not currently using the control rig, but it's original rig.

This guide to re-targeting in Motion Builder looks like it can be very helpful in the future if I were to get more in-depth into Motion Builder:
http://mocappys.com/retargeting-animation-motionbuilder/#.XHGKu-hKiUk

In the future, I think I will leverage both programs for what they do most effectively. Instead of re-targeting in Motion Builder, I think I will decide to edit the Mocap skeleton's animations in story mode to make them looping, then bring that into Unity and re-target there. However, there are still other nice features that Motion Builder offers. If I need to do something that requires precise control over part(s) of the body, such as closing the fingers to grip an object, like my character's rifle, Motion Builder allows for that. To solve this issue in Unity, I will need to use avatar masks for the hands.

In the future, I foresee that I may never need to use Motion Builder again, and will be able to pretty much do everything with re-targeting animations in Unity.

No comments:

Post a Comment

All Updated State Machines and Blend Trees

These are all of the State Machines and Blend Trees that I set up for my character in Mecanim: