Showing posts with label Unity Retargeting. Show all posts
Showing posts with label Unity Retargeting. Show all posts

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.

Friday, February 22, 2019

Unity Mecanim or Autodesk Motion Builder?

        I have determined that Unity's animation retargeting system in Mecanim can be very powerful, but that it is ideal if you already have finished animations. If I were, say, doing a project using primarily or almost entirely animations from the Unity asset store or some other online marketplace or community, then Unity Mecanim alone would be perfect. I would just funnel in the animations from all of these outside sources into my project and character.




        Straight away, it's pretty cool, you just drop your character rig into the project, and it automatically recognizes if if your character is in t-pose. You may need to configure the avatar, but you don't need to go through the tedious process of characterizing your character like in Motion builder. You can also correct your character, rotating the joints to fit t-pose, much like Motion Builder, but that's where the similarities end.

        I found this video training comprehensive overview of Mecanim very helpful, much of it was review, but still made certain things like Blend Trees easier to understand. Much of it was not review.

https://www.youtube.com/watch?v=wf6vtCgLk6w

        Most of what I needed to know was in the first half-hour. At 51:00, he mentions root transform offset and some other helpful things. At 1:15:00, mentions useful State Machine Behavior script components. Damping, 1:21:00.

        I discovered that one can do many interesting things in Mecanim, such as setting up muscle space, which is pretty much limiting the rotations on the character's joints, which can come in very handy if you want to make your character more or less flexible.
        I also hit Unity's documentation this week, exploring different things I can do in Mecanim.

https://docs.unity3d.com/Manual/animeditor-AnimationEvents.html



        While Mecanim is very powerful, editing animations in Mecanim seems to be very manual, setting keys and editing curves in a dope sheet much like Maya, Blender, or some other 3D package. My key-frame animation skills are not very good. In concept, I can manually edit animations in Mecanim. Even so, I feel that that would be very time consuming and inappropriate for this project and out-of-scope, considering the remaining time frame.

        Immediately after shooting MoCap, the animations are not ready to go into the engine. The MoCap rig rarely ever matches up perfectly or adequately with your character rig. So, editing always required, to ensure that the animation is in-place, and that the positioning of the limbs are correct so that there is no clipping. For this project, I need the extra functionality that Motion Builder has because it allows me to edit animations efficiently, via animation layers. The MoCap animations that I have are not finished, they are not in-place, and not yet suitable for use in Unity. For this project, I need to use Motion Builder.

         I can definitely see myself using Unity Mecanim in the future, so I do want to continue familiarizing myself with the capabilities that Mecanim has to offer, as I am very excited now that I have discovered these. I could possibly use it next quarter in New Media Project, or further along in the future, in place of Motion Builder, because Unity is free, Motion Builder is not.

Tuesday, February 19, 2019

Unity Mecanim Animation Retargeting

I already know how to retarget animations in Motion Builder, so now I will examine Unity, and see if I will utilize it instead. Unity seems like it can be a cost-effective alternative. I will use Unity if it is an effective tool that I can learn to use quickly. I have gathered some tutorials and Unity documentation links.

Tutorials:
https://www.youtube.com/watch?v=dDHltGGDrAA

https://www.youtube.com/watch?v=3TOJt9tntNI

https://www.youtube.com/watch?v=7yGBu97Oej0


Unity Documentation:
https://docs.unity3d.com/Manual/Retargeting.html


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: