For those who may have missed it in the news section, Mixamo did a press release with Unity the other day announcing some tighter integration of the Mixamo service for Unity users. Mixamo provides an online motion capture and retargeting service that lets you tune data from their motion capture library and download it ready to go for your own character. As part of their release, they also posted up a sample Unity project with a component I created for them, the Root Motion Computer.
The basic idea behind the Root Motion Computer is that it allows you to use actual forward movement in your animation data to move your characters around, which can be helpful for moves where a character’s speed or orientation changes during the course of an animation. I created a short video to demonstrate it, which you can also find at the Mixamo site along with the project for download, though I also posted the video to my Vimeo account in higher quality so it’s a little easier to see everything:
This is really fantastic and will be extremely useful in a current project. I didn’t notice any specs for rigging the character model to work best (or at all) with the Root Motion Controller. Are there any particular requirements for that, or does it just need to comply with general Mixamo rig requirements?
I implemented a fair bit of auto-detection to try to set things up for the user based on normal situations, but you can configure everything manually in the inspector if you like (e.g. which animation component to use, which transform is the root node, which object is the pelvis, and so on).
The only basic requirements are a) the root node has no animation data applied to it, b) the root node is hierarchically above the pelvis object, and c) the pelvis object is the top-most bone in your skeleton. However, it is certainly possible to work around any of these requirements easily enough if you desperately want a weird rig. Beyond that, it should be pretty flexible.
If you try it out and have difficulty getting it to work with your setup then let me know and I’d be happy to help.
ok! i may bring this post from the dead but i mostly wanted thanks and also to specify that, as an animator, i was dreaming of a script like this on unity! big thanks! now, i cant wait to see an animation statemachine! (i wish i could script:?.. anyone wants to take the contract? msg me:P)
otherwise, if i can comment on something for your script, it would be great to be able to key the root in the 3d software and having it not pat of the hierarchy to be able to have more control on transition poses for classic animation trans and/or to deal with the rotation on a straith value to manage the blend between 2 degrees (like blending a 180 turn with a 90 turn to get 120 turn proper motion)or even better rootmotion to make cinematics. I suggest this because this is the way i worked on other game projects who was strongly based on animation quality and it was a charm to have that to work with on our animations!
in the end, thank you a lot to share this script, now i feel even more confident to complexify my animation system for my project!
I have been testing out the path using this script in Unity. I have been able to get working for the most part. I am however seeing some weird behavior in the animation when they loop back. Every so often my character animation will loop incorrectly for what seems like a single frame. This will happen inconsistently while walking or in idle. I can’t figure out what is causing this to happen, I am certain that the animations are working correctly… they loop perfectly in max or motion builder, but it seems like something in the program doesn’t update as quick as it should periodically. I know this may be difficult to diagnose, but do you guys have any idea at all what might cause the behavior I am seeing using this script?
Thanks for this great tool, Adam. I had tried to implement the same thing previously myself but didn’t have this degree of success.
Do you have any suggestions on how the RMC could be used in networked games? Would it just be a matter of allowing it to run normally on each client machine and sending the pelvis offset along with other motion data? I guess the challenge there would be correctly synching the animation playback. Even more of a challenge would be using this system to playback animations on server controlled NPCs.
Given the last comment about performance, would there be any value of using the RMC to generate a lookup table of pelvis offsets and simply reusing those?
The idea behind root motion controller is simply amazing!
I tried to use DAZ character with it. I’ve made simply walk animation, 2 steps forward.
BUT, after animation finished, character gets back to where he was. I guess, DAZ animates root along with the character, and that is the cause of the problem??
The RMC is great for things with minimal amounts of characters … say a boxing game But a survival game where you have hundreds of guys running at you … not so much.
It’s also phenomenally useful when it comes to dealing with cut scenes. Anyone that has had to deal with in-game cut scenes can immediately see the benefits here.
I wish i knew how to improve the performance of the Animation.Sample, it does appear to be different per character (presumably the animation data differs thus different processing time).
It’s cool I had high hopes for it in a game were working on, unfortunately just not scalable enough.
Thanks for the great script ! i recently started using it. I was wondering if you have an example of how you would code jumping with this properly? And how you would have the character controller follow the mesh since it seems to stay on the ground during jumps?
After updating to Unity 3.4, all my chars with mixamo controller attached has their hair positioned wrong. Hair is just a parent object, attached to their head bone. Any idea what might be causing it?
I noticed that too. I commented out some code to fix a similar problem for me:
// determine the contribution to the root's delta this frame based on whether the animation looped since the previous frame
// if (info.previousNormalizedTime-(int)info.previousNormalizedTime > info.currentNormalizedTime-(int)info.currentNormalizedTime)
// {
// // compute displacement with respect to identity
// p = info.contributingWeight * ((info.endPosition - info.previousPosition) + (info.currentPosition - info.startPosition));
// if (isRotationMode)
// {
// // rotate displacement into current orientation
// p = Quaternion.FromToRotation(info.currentAxis, info.totalRotation*Vector3.right) * p;
// // compute angular displacement and append to result
// dRotation *= Quaternion.Slerp(Quaternion.identity,
// Quaternion.FromToRotation(info.previousAxis, info.endAxis) * Quaternion.FromToRotation(info.startAxis, info.currentAxis),
// info.contributingWeight);
// }
// // append displacement to result
// dPosition += p;
// }
// else
I also added this since my armature (3d model was created in Blender) was rotated 270 in the x axis. Its easy to find where this code fits to, search for “pLocalPosition” and change what it has to this:
// prevent the pelvis from moving, except in world-space y-axis
/// \todo what if we also want to track world-space y-axis movement? (climbing a ladder animation that has irregular upward movement?) we'd zero the pelvis local position in all axes right?
// store the local position of the pelvis before returning it to hover over the root
pLocalPosition = pelvis.position - pelvis.parent.position;
// zero out the local x-component of the position delta if root translation method is z-only
if (computationMode == RootMotionComputationMode.ZTranslation) dPosition = Vector3.forward * Vector3.Dot(dPosition, Vector3.forward);
// otherwise zero out the local x-position of the pelvis
else pLocalPosition.x = 0f;
// return the pelvis to a point hovering over the root
pLocalPosition.z = 0f;
pLocalPosition += pelvis.parent.position;
pLocalPosition = pelvis.parent.InverseTransformPoint(pLocalPosition);
pelvis.localPosition = pLocalPosition;