Rigging for Inverse Kinematics

From TOI-Pedia

Inverse Kinematics is a way of animating in which you determine the end position of a controller to create the desired movement. It acts in the other direction then Forward Kinematics, so it moves the character from the bottom of the hierarchy up. So, for instance to get a character to walk, you animate the endpoint of the foot and Maya determines the way the leg follows to get the walking motion. Of course you can also influence the way in which Maya makes the leg move to get the end position of the foot, but you have less control over it than with Forward Kinematics.

Important!! Check before you start rigging that:
  • the skeleton fits the character
  • the hierarchy of the skeleton is correct
  • the skeleton is placed at the origin of the scene
  • maybe most important, your joints are oriented correctly (skeleton > orient joint)

Inverse Kinematics for a leg

IK handles

IK Rotate Plane solver

To use Inverse Kinematics (IK) you need to create an IK chain with IK handles. First you need to determine which bones and joints need to belong to the chain. To do this we go to the IK handle tool under Skeleton > IK handle tool > optionbox. In the optionbox you can choose between an ikSCsolver and an ikRPsolver. For the handle controling the leg we want to use an ikRPsolver, so we choose that one in the tool settings. Now click on the hip joint and then on the ankle joint and press enter. Now an IK chain has been created between the hip knee and ankle:


The white triangle shows in which direction the knee will bend. If you now move the IK handle at the end effector at the ankle you see that the entire leg bends with it.

Linking an IK handle to a control curve

We don't want to move the leg by the ankle all the time, it would make a lot more sense to move the foot as an end result. To do this we have to create a control curve that represents the foot and link the Ik handle to it. First we'll create the foot by creating a nurbs circle and placing it at the right spot. Also give it a logical name like lFootControlCurveIK. When you are happy with the spot and shape, freeze the transformations:


To get the IK handle to move along with the IK foot control curve, parent it to it by middle mouse button (MMB) dragging the ikHandle onto the lFootControlCurveIK in the hypergraph (or by first selecting the IK handle, then the control curve and going to edit > parent):


If you now select and move the only lFootControlCurveIK you see that the IK handle moves along, and thus lets the knee bend:


Creating a no-flip-knee

A problem now is that if you move the ankle in a position above the hip joint (like in a kick), the knee joint flips:


This flipping is caused by the pole vector and the handle vector crossing each other. You can avoid this by selecting the handle and putting in 0.1 at the pole vector x entry, 0 at the pole vector y and z, and using a twist of 90, now the knee doesn't flip anymore:


However, if you want to rotate the knee the twist value is already set to 90, it's easier to have a channel that is default at 0, so that the value of the rotating will be the actual rotation of the knee. To do this we are going to create a new attribute for that on our foot control curve (because the foot control curve operates the leg) and use an expression. Before we do this we need to create 2 extra attributes on our foot control curve, so select the curve, open its attribute editor and go in the attribute editor to attributes > add attributes:


Now create 2 attributes of the float type with the names 'knee' en 'offset'. The knee attribute will control the knee rotation, the offset will be used as an aid to set that value to 0 instead of -90:


Now we have to create an expression on the 'twist' attribute of the ik handle to get that value to be dependent on the value set at the 'knee' channel of the foot control curve.

To do this we select the IK handle and click with our right mouse button (RMB) on the text 'Twist' in the channelbox. We select 'expressions' from the menu that appears when you keep your RMB pressed. The expression editor appears:


Give the expression a name (for instance kneetwist) and type (in this case) the expression:


and press create:


If you named your objects and/or the added attributes differently type as expression: nameOfIkhandle.twist=nameOfControlCurve.nameOfAddedAttribute+nameOfControlCurve.NameOfSecondAddedAttribute.

You can see that the knee twists 90 degrees, to correct this you have to enter 90 degrees in the offset field in the channelbox of the foot control curve:


You can now lock and hide the offset channel of the foot control curve by RMBclicking on the text offset and letting go above lock and hide selected. We can now only use the knee channel of the footcontrol curve to adjust the angle of the knee:


IK Single Chain solver

Now we need to make sure that when we lift the foot the foot joints will stay straight. We can do this by creating IK handles for the foot joints as well, and parenting them to the control curve too. This time however we don't need that much control over in which direction these joints bend, so after selecting the IK handle tool by going to Skeleton > Ik handle tool > optionbox we choose the ikSCsolver as current solver and create a handle between the ankle and ball and between the ball and toe joint:


We also parent these 2 IK handles to the control curve. Now when we move the control curve the foot remains straight:


Inverse Kinematics for an arm

To create an arm which can basically do the same as a real arm you need to simulate the movement that your forearm allows: to be able to rotate your wrist without moving your elbow. In the section the auto forearm twist this will be discussed fully, in this section we will only cover the inverse kinemtics part of this movement, so only how to move the wrist (and with it the arm). To do this your skeleton needs to be a bit different than a real skeleton; you need to create an extra joint between the elbow and the wrist. This joint needs to be in a straight line between the elbow and wrist. If your skeleton doesn't have a 'forearm joint' yet, you can create one by disconnecting the arm at the elbow joint (select the elbow and go to skeleton > disconnect joint), then drawing a curve between the elbow and the wrist (use pointsnap), then selecting the elbow joint (the one with the wrist under it), pressing insert, moving the elbow joint along the curve (use curvesnap), pressing insert again and then MMB dragging the chain (again the one with the wrist under it) onto the elbow again in the hypergraph ( a new bone between the elbow and forearm will be created). Name and label the joints:


Ik handles with polevector constraint

We now want to control how the elbow moves. Create an ikRPsolver IK handle between the shoulder joint and forearm joint by going to Skeleton > IK handle optionbox, choosing the ikRPsolver as current solver and clicking on the shoulder joint and the elbow forearm joint:


We now want to make sure that the elbow always bends in the same direction, so we want to contrain the polevector of this IK handle. To do this, first create a locator (create > locator), place it somewhere behind slightly the shoulder and freeze its transformations (modify > freeze transformations):


Now pole vector constrain the IK handle to the locator by first selecting the locator, than the IK handle and then going to constrain > polevector:


Parent the locator used as a polevector constraint to the pelvis by MMB dragging it onto the pelvis in the hypergraph.

Back to Skeletons

Overview of Maya topics

Maya main index

link title

Personal tools