- The search for the perfect
inverse kinematics rig in Blender, and in other softwares, is a never ending quest, and it has been tackled many times. I'd like to answer this question today. What's the perfect inverse kinematics rig? We will use a leg as an example as it's the most common
use of the IK mechanism, and I believe it's
understandable by everyone. So let's get started. (logo whooshes) I push this rig way
further in my rig course but here I want to focus on the inverse kinematic mechanism itself. I won't be building any footholds
or corrective mechanism. You can download the Blender
files to follow along on p2designacademy.com for free. Also, I'd like to let you know that I'm running an exceptional sale to celebrate reaching the
100,000 subscriber mark here on YouTube. Find more information in this video and in the video description below. As you will open the file,
you will find two rigged leg, a simple bone chain
driving the deformation of the leg and the rig bone. Those two rigs are
identical and will allow us to compare what we are
doing along the way. Let's build our simple
inverse kinematics mechanism. I will select the foot bone
in edit mode, duplicate it, and scale it down, and
rename it "IK foot". Now, by default, it's
parented to the shin, so I will press "Alt P"
and clear the parenting so that now this bone is totally free and there won't be any cyclic dependency. In post mode, I will select
the inverses kinematic foot, then the shin, and I
will press Ctrl+Shift+C to add an inverse kinematic constraint. I can immediately set the
chain length to two bones, the shin and the thigh bone, and test my rig moving the controller. If I go in front view and
I move it left to right, I get some weird deformations because your knee is not
supposed to bend sideway, but we can find specific
inverse kinematic properties under the bone property. Here I can tell the bone
not to rotate around the X and Y axis to solve the
inverse kinematic mechanism, so basically, I want
the shin to only rotate around its local Z axis, and I know that because I built the rig
and if I display the axis, we can see that I'm
rotating around the Z axis, and this is the best default orientation because if you want to create
a pole target, the X axis of the owner of the constraint
will naturally point toward the pole target, so basically I want my local
X axis to point forward in the knee direction. This can be adjusted in the constraint tweaking the pole target angle value, but that's not the point of this video. When I move the inverse kinematic control, the leg follows, but I don't
have control over the foot. So I can first select the controller then the foot, press Ctrl+Shift+C, and add a copy rotation. Now the foot follow the
rotation of the controller, and yes, you just heard one of
my chicken in the background, but the foot is not following the location nor the scale of the controller. To fix that, I need to
add a copy transform and since the copy transform constraint also covers the rotation, I can get rid of the copy rotation constraint, and this is our very basic
inverse kinematics rig. I just reproduced the exact
same rig on the other leg, and what I want to show you here, is what we call knee popping. As we get closer and closer
to a full extending leg, the knee accelerates backward
in a very snappy motion, and that's a common problem for animators. The solution you will
find in most tutorials, including mines, is to
enable IK stretching. Let's use a value of 0.05. Any value below 0.1 will
give the same result. I will set this value on all the bone of the inverse kinematic chain, the shin and the thigh bone, so now when I pull on my
inverse kinematic controller, you can see the leg
getting bigger and bigger. So it's basically stretching in a way, because when I think of stretching, I think of uneven scaling
with volume preservation. Here the bones are just evenly scaling up but we'll think about this later. Now, when I move both controller you can clearly see the difference in the way the full extension of the leg is solved and
we get a softer motion on the left knee. With IK stretch enabled, the
inverse kinematic mechanism changes the scale value of the legs along with rotating the different bones to solve the mechanism and basically follow the
inverse kinematic target, what we generally call the
inverse kinematic controller. The highest to the IK stretch value used, the more scaling will be
used to solve the mechanism and so less rotation will happen. Values going from zero to 0.1
have exactly the same behavior so I was able to build
some kind of soft inverse kinematic mechanism generating a softer rotation of the knee, but it means that my leg gets scaled and I don't want that. Here it's subtle, and it's an
organic shape, so it's fine, but on art surface that
won't look as good. To fix that, let's pretend
that the left and right leg are the same, but we have
an inverse kinematic chain driving the deformation chain. To get the same behavior, I will add a copy, transform constraint
on the second foot, following exactly the same movement as the first foot in local space, and I want the same rotation
behavior of the leg bones as the one with the soft
inverse kinematic mechanism so I can get rid of the
inverse kinematic mechanism on the right leg, and then
simply add a copy rotation from the left leg to the right leg. When I move the left foot, my
inverse kinematic mechanism, the right leg rotates the same way but the foot follows the controller and we get a weird leg shape. To fix that, we can tell the foot bone to stick to the shin bone. To do so, we can use a
copy location constraint from the shin onto the foot
following the tail of the shin. This now looks way better. We have a consistent leg
shape wherever the position of the controller, but the problem is our foot is no longer following the inverse kinematic controller, and as soon as we extend
the leg, for example, in the walk cycle, the
foot on the right leg will have a arking motion. It won't stay on the ground, and believe me, this will
show in your animation. So let me exaggerate the motion so that you can clearly see this arking. If my left leg,
representing the controller, is straight on the ground
and slightly overstretched, you can see that the foot is no longer sliding on the ground
but kind of balancing like a pendulum or whatnot. So this mechanism doesn't work. Let's find another solution. Basically what we need is
to control the distance between our inverse kinematic controller and the root of the
inverse kinematic chain, but you may not want to use
a limit distance constraint. I try a different combination
and it's not ideal because the distance is an absolute value and one meter on the human being and one meter on the
hand won't look the same. What I mean by that is the
limit distance constraint is prone to error or bugs whenever you want to change
the scale of your whole rig, so we will prefer to use
a limit scale instead. Our hips bone is the parent of the leg so it'll also be the
parent of our scale bone. The scale bone will start
at the root of the leg, so I can select in edit mode
the head of the old leg bone and extrude it. I will rename it MCH leg length, I will select the ankle joint, snap the cursor to it, pressing Shift+S, and then snap the tail of
my length bone to the ankle. This length bone will be used
to control the target bone of the inverse kinematics chain, so we need to create another
inverse kinematic bone. We will have one controller
and one target bone. In edit mode, I will duplicate
the inverse kinematic bone, scale it down and rename it MCH_IK_FOOT, and then I will parent it to the inverse kinematic foot bone. You can use the select
menu using Alt+Right click or Alt+Left click, depending
on your configuration. Now in post mode I will first select my inverse kinematic controller, then Shift select the length bone, press Ctrl+Shift+C, and add
a stretch to constraint. When I move the IK controller, we can see the length bone stretching. Let me get rid of the axis
display because we don't need it. It'll be a little clearer. My MCH_IK_FOOT is a child
of the IK foot controller, so it does what the IK
foot controller does, but I want it to stay in a given range driven by the length bone, and to do so, we'll use a copy location. In post mode, select
first the length bone, then the MCH_IK_FOOT
bone, press Ctrl+Shift+C, and add a copy location constraint. By default, the bone will snap to the head of the length bone, so let's
change that in the constraint and set the tail value to one. Now I want the MCH_IK_FOOT
to be the target of the inverse kinematic constraint, so let's select our shin bone and let's edit the inverse
kinematic constraint, and as a target, use the MCH_IK_FOOT. If we now select our inverse
kinematic controller, the IK foot, and we move it, the MCH IK bone follows triggering the inverse kinematic
mechanism, nothing new. So if I want to limit the distance at which this MCH_IK_FOOT
travels, I simply need to add a limit scale constraint
to our MCH length bone. We want to limit the
stretching of the bone so we want to limit the maximum Y value. By default, it is set to zero, so now our bone is really small. We want to use the local space of the bone and let's start with a scale value of one. As I confirm this value, we can see that our length bone is shortened. The MCH IK bones follow, thanks to the copy location constraint, and so does our inverse kinematic chain, but the foot is still
following the controller. This is why we have
this weird deformation. So let's fix this. I don't want the ORG bone to follow the foot controller
anymore, I want it to follow the MCH_IK_FOOT. Right now it has a copy
transform constraint following the IK foot, the controller, so let's get rid of it, and, instead, add a new copy transform constraint targeting the MCH_IK_FOOT. Select first the MCH_IK_FOOT, then Shift select the ORG
foot bone, press Ctrl+Shift+C, and choose copy transform. The MCH_IK_FOOT does
everything the IK foot does but its location is limited
by the MCH leg length, so now we can slightly increase the length of the MCH leg length to
get a full extended leg, let's say 0.05 for example, and the MCH IK bone won't
go beyond this limit. So we get our soft IK, we
get a limit in the length of the leg so we don't
get this weird deformation between the foot and the leg. The result will be less jittery than when using a copy rotation, but as long as you limit the distance there will be a threshold
where you will still have this pendulum effect. The only way to get rid of it
is to not use a limit scale. It's to not use a limit at all. I know it's often reinsuring for beginners to have this limit, but as an animator, I do
believe it's the animator job to set the limit visually assuming that we will face other problem, so let's solve them. Since I decided it's the animator's job to decide how much the
leg should stretched, then let's get rid of
the MCH leg length bone and out comes a new problem. I still have my soft IK, but if I pull the leg, I get
this weird inverse kinematic stretching that is more of uneven scaling, that's a real stretching
with volume preservation. How can we solve that? We will need a second bone chain. Select both leg bone, press
Tab to enter edit mode, Shift+D to duplicate them, and then Shift+H to hide everything. I will rename those bone
MCH_leg_IK and MCH_shin_IK, and as we switch to post mode, the inverse kinematic is already set on it since we duplicated the chain with the inverse kinematics constraint. Let's move the MCH bones to another layer so that it's a little bit clearer. As always, I'm using
the bone manager I done by my friend, Finn. It's a must have so far for rigging as you can name the layers and it has so many functionalities. On our original chain, we don't need the inverse kinematic constraint anymore. Press Ctrl+Alt+C to get rid of it. Now, we need to enter a edit mode and duplicate those two
bones and make them smaller. As I scale them down, I can see that they are still connected so I will press Alt+P and
disconnect the parents. They are still parented but
they're no longer connected, and I can now scale those new bones down. Now what I want is to
parent those two bones to our MCH inverse kinematic chain so that they follow the
inverse kinematic movement. We can do that entering edit mode and instead of using the Ctrl+P shortcut, we can go in the bone
properties and under relations, type in the name of the bones we want them to be parented with. I like this way a lot whenever my rig is getting more complex. If I now move the foot controller, we can see that those bones are following the inverse kinematic chain, but our original bones don't follow, so what we can do is tell them
to copy the transformations of those new bones. So let's first select the small bone, then Shift select the leg bone, press Ctrl+Shift+C, and add a copy transform constraint. We now need to do the same with the shin. So let's select the small shin bone, then the shin bone, press Ctrl+Shift+C, add a copy transform constraint, and we are back to square one. When we move the foot, those
new bones follow their parent, the inverse kinematic chain, and they influence the original bones, but we can now tell them to follow the scale of another bone, for example, the root bone,
which isn't scale at all. So let's add a copy scale constraint to those small bone, targeting the amateur and the root bone. As we do so, we're getting a
critical change in our rig. So let's go ahead, select
the second small bone, and then add to it a
copy scale constraint, targeting the amateur and the root bone. You can see that the shin
bone is not following its corresponding small bone and this is because a
copy transform constraint doesn't override the location
transform of a connected bone, so we need to select our original bone, enter edit mode, press
Alt+P and disconnect it. Now we do have some kind of separation but we don't get a real stretching. Only the knee and ankles are
deforming, not the whole leg, and this is the final step. I will select all my
bones and reset the pose. Press Alt+R Alt+G Alt+S to
cancel the scale, location, and rotation of the bones, then use the small shin bone
to add a stretch to constraint onto the original leg bone, and then we can use our MCH_IK_FOOT to add a stretch to constraint
onto our original shin bone, and voila, if I select my
inverse kinematic controller and I move the foot, we can
see that we can stretch it with a proper volume preservation, we can scale the foot, and we still have our soft IK mechanism, but this rig, as is, can be used for game animation because
with bone stretching we get uneven scaling,
and with uneven scaling we get a lot of bugs when
it comes to game engines. Now we don't need four
additional minutes to solve that. Instead of using a stretch to constraint, we can use a damped track constraint. We keep the soft inverse
kinematic mechanism. We can slightly stretch the
leg as the bones will separate. You don't get volume preservation, but if you don't overstretch the leg, it looks pretty natural, and your game engine will
thank you about this. Then to finalize the rig, I
advise you to add a pole target. I just wanted to save time
not setting a pole target on all the chains we just created. So to conclude, what's the
perfect inverse kinematic rig? Well, I don't know, you
have to pick one of them. The PACE inverse kinematic
mechanism without IK stretch is the best for mechanical parts because your joints will perfectly follow, but when it comes to organic
mechanism or organic shapes, then it's up to your animation style or your target platform,
feature animation, or game animation. This is the end of this video. I hope you enjoyed it
and learned something new and I will see you in the next one.