For a while now, I've
been trying to find an easy to use method for combining ragdoll physics
with mocap animation, for example, for getting up after a fall. With, shall we say, limited success... The reason I kept failing, was
because I was trying to make everything really complex, trying to do everything with one rig. By simplifying things as much as possible, I was finally able to mix ragdoll
and mocap animation. A big “thank you!” to Rokoko for making this video possible. First, you'll need a ragdoll
that has rotation constraints so that its arms and legs
don't move in impossible angles. I've described in previous videos
how to make this kind of ragdoll. But, since I've already made it
and fine-tuned the constraints, you can skip all that work
and just download it from my website. Note, that the hitboxes
have to be set to Start Deactivated. That way, the physics simulation starts only after they're hit
by another object. As a side note,
the Rigid Body connection Empties have to be parented to the hitboxes,
so that the connection works well. But don't worry,
this has already been taken care of in my Ragdoll file. Then record some mocap actions
for your scene. If you need some special kicks or actions
that you're not able to do, or you don't have a mocap suit,
the Rokoko app has a Motion Library of performances that you can choose from,
including some free ones. In case your character
still needs to be rigged, I recommend doing this online in the free online Mixamo auto-rigger. Make sure that you download it in a T-pose,
and check Automatic Bone Rotation when importing the file. As you can see, the auto-rigged
character is now in a T-pose compared to the
‘kind of T-pose’ it was in before. This will help a lot with properly retargeting the animation. I like to set the Armature to In Front
and to display as ‘Sticks’. Import the FBX
file of the mocap animation and use the free Rokoko
add-on to retarget it to your characters. I highly recommend
renaming the Armatures in advance. That will avoid confusion
during the retargeting process. Pick the Source and Target Armatures. Click on Build Bone List. Check the Bone List for any mistakes.
And then click on Retarget Animation. You can delete the source Armature. In this video I’m using the Animation Layers add-on. It’s a commercial add-on, and if you want a free alternative, I did make a couple of videos that you can check out. I recommend getting this add-on if you often do animation in Blender. To use it, first enable it. Then add a new layer. Turn on auto keying and add some adjustment keys. And that’s all. It’s a very easy to use add-on and it really makes animating in Blender much more fun. Just remember to turn off auto-keying at the end. Append the ragdoll
from my ragdoll Blend-file. Open the Collections folder inside of the file. And append the “Ragdoll” Collection. Go to frame 1. Go to the point
where your character has to do a stunt. Move it to rougly overlap the character. Parent a Passive Rigid Body, set to Animated, to the Bone of whichever body part
first collides with the ragdoll. Here I’m moving the 3d cursor to the selected Bone. Then any object added, like a Cube, will be in that location. Scale it down. Turn the Cube into a Rigid Body. Set it to Passive and check “Animated”. Hold Shift and select the Cube and then the Armature in Object Mode. Then go to Pose Mode. Parent the Cube to the Bone with Ctrl+P > Bone. The Passive Rigid Body Cube now follows the foot. Now Bake the Rigid Body cache. The floor needs to be a Passive
Rigid Body object. Instead of parenting a Passive Rigid Body to the kicking foot, you could also use a separate animated Passive Rigid Body object. That way you have more control over the speed and the movement. Once you’ve got something that you’re happy with, select all the hitboxes while holding Shift. Then bake the simulation to keyframes. Now we have the Rigid Body cache baked to keyframes. This way, we can’t accidentally lose the Rigid Body animation. You can now hide or delete that Cube. One issue we need to fix is that the Rigid Body animation starts too early. Select all the hitboxes in the Ragdoll collection. Then move all the keyframes a couple of frames forward in time. You can move the keys by pressing G. Now the impact looks better. Unhide the hidden character and create a new Animation Layer. Rename the new layer “stunt” for clarity. Go to Pose Mode. Make sure that Auto Keying is enabled. Select all the bones and set a Location & Rotation keyframe just before the impact. Then move forward in time a few keyframes, and pose the character to match the ragdoll. The poses don’t have to perfectly match the ragdoll, as long as it looks okay. After finishing one key pose, go forward in time a few frames, and do the next one. To make things easier to see, select all the hitboxes... Then while holding Alt, check the In Front option. And while still holding Alt, set Display As to Wireframe. Whenever you have bones that are in a really weird pose, you can select them and then press Alt+R to reset their rotation. You don’t even really need to set that many keyframes. You can set more keyframes, to accurately follow the ragdoll, but I find that a small amount of keys already looks fine. It depends on how realistic or stylized you want the result to be. Finally, add mocap for the part after the ragdoll animation,
when the character gets back up. I recommend importing the mocap FBX in a fresh Blender file that has your character in it. Then retarget the animation as you’ve done before. You can delete keyframes that you don’t need. Because the physical difference between this character and myself, there’s some clipping of the hands into the body. To adjust this, you can open the Graph Editor window and then in Pose Mode select a bone that you want to adjust. Press the Home key if you don’t see any of these keys in the Graph editor. Double-click on one of the rotation channels. Then move the keys up or down on the Y-axis by pressing G and Y. This way you can make some quick adjustments. Open a Dope Sheet window and set it to Action Editor. Then name this Action appropriately. Then, save the file with a clear name. Back in our main file, open a Nonlinear Animation window. Click this button to see only the animation of the selected object. Append the Action from the other file. Select the top layer in the Nonlinear Animation Editor. Add a new Track. Select the new Track and press Shift+A. Choose the “Getting Up” Action. Find the right point to start the Action and press Y to split it. Then you can delete the part that you don’t need. Set a Blend In value of 1 frame. We need to move this Action forward in time. It looks like it should start around frame 400. As you can see the getting up Action starts in a very different location. Normally it would be easy to solve this by simply moving the Root bone and setting keyframes for that. Unfortunately, Mixamo rigs mysteriously don’t have Root bones. However, we can still kind of add a Root bone ourselves. In Edit Mode, extrude a Bone. In this case I extruded it from the Hip Bone. Name it the Root Bone. Select the Hips Bone, and parent that to the Root Bone. Now we can use this improvised Root Bone to change location and rotation of the character with some keyframes. Add a new animation layer. Select the Root bone in Pose Mode. Go to the last frame of the Ragdoll animation. And set a Location / Rotation keyframe. Then go to the next frame, and position the Armature where it should be. I recommend using Auto Keying for this, so you can quickly iterate and find the right pose. Press back and forth to toggle the previous/next frame and compare visually where it should be placed. Now that the position is solved, there’s still some ugly movement where the next Action suddenly begins. Before we fix that, let’s give a proper name to this animation layer. Create a new animation layer. On the last frame of the Ragdoll animation, select all the bones except the Root, and set a Location / Rotation keyframe manually. Go forward a few frames and set another Location/Rotation keyframe. Copy the pose of the last frame of the Ragdoll animation with Ctrl+C. Go one frame forward and paste the pose with Ctrl+V. Set a Location / Rotation keyframe so that the pose is recorded. Now we need to move the Armature back to the right location. I recommend turning on Auto Keying for this. Like before, fine-tune by visual comparison while toggling back and forth between those 2 frames. When that’s done, don’t forget to turn off Auto Keying. Now the Ragdoll end position blends to the getting up Action. The blend is too fast so we’ll need to move that last keyframe. That looks better. Using this technique, we can create many
seamless animations with ‘virtual stunts’. One last tip, if you run into these kinds of shenannigans
where the Ragdoll explodes all over the place when you move it, One thing you can do is just temporarily remove the Rigid Body World. Then you can move the Ragdoll, and add the
Rigid Body World back when you’re done. Check my Mocap Playlist for more motion
capture related videos, or click the link to go to my website
and download the ragdoll file.