Combining Inverse and Forward Kinematics

From TOI-Pedia

Both Inverse and Forward Kinematics have their advantages and disadvantages, so to get optimal control over your skeleton it is also possible to use a combination of both.

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)

Creating an IK/FK switch

What we'll do is make 2 copy's of our leg: one of them will be a FK leg that responds to Forward Kinematics and one of them will be an IK leg that responds to Inverse Kinematics. We also need to make a 'switch' that controls how much the original leg will respond to the IK leg and the FK leg. So first duplicate your leg from the hip on 2 times and name them conveniently, in this case we'll name 1 leg lHip, lKnee, etc, 1 leg we'll name lHipIK, lKneeIk, etc, and we'll name 1 leg lHipFK, lKneeFK etc:


The hypergraph is a very convenient window to use while doing the things discussed in this section. To rename something in the hypergraph press control on your keyboard while double clicking on the name.

Provide the IK hierarchy with the needed handles (and foot control curve) as is explained in the section Rigging for Inverse Kinematics and the FK hierarchy with the needed control curves at the joints as is explained in the section Rigging for Forward Kinematics:


Now orient constrain all the joints of the lHip hierarchy to their IK equivalents. So select the lHipIK first, then with shift the lHip and go to constrain > orient, do the same for the lKneeIK and lKnee, for the lAnkleIK and lAnkle, etc.:


Also orient constrain all the joints of the lHip to their FK equivalents. So select the lHipFK first, then with shift pressed the lHip and go to constrain > orient. Do the same for the knee, the ankle, ball and toe.

Now if you rotate the FK chain or move the control curve of the foot of the IK chain you will see that the lHip hierarchy will be an average of the Ik and FK chain:


We now want to have control over how much the lHip hierarchy follows the IK or the FK chain. To do this we'll make a 'switch' on our foot control curve. To do this we need to create an IK-FK attribute on this curve. So select the lFootControlCurveIK and open its attribute editor by pressing ctrl+A on your keyboard. In the menu attributes choose add attributes:


Name the new attribute IK_FKswitch and make sure the data type is set to float. Give it a minimum of 0, a maximum of 10 and a default of 5 (in this way both the IK and FK leg have by default an equal amount of influence). Press ok when done:


When you select the curve and look in your channelbox you can see that an extra attribute with the name IK_FKswitch has been created.

Now you have to open the set driven key editor by going to animate > set driven key > set... In this set driven key editor load the lFootControlCurveIK as driver by selecting the curve and pressing load driver. Load as driven the orient constraints on the lHip, lKnee, lAnkle, lball and lToe by selecting them all in the hypergraph and pressing load driven:


Now select select the curve again and make sure that in the channels the IK_FKswitch attribute has been set to 0. Now select the IK_FK attribute in the left section of the driver section in the set driven key editor:


Now select one of the 5 constraints in the driven section in the set driven key editor and select both the bottom two attributes in the left field of the driven section. Set one of the bottom 2 channels in the channelbox to 0 and the other one to 1:


Now make sure that the IK_FKswitch is still selected in the set driven key editor and that the bottom two attributes in the right field of the driven section are still selected and press key in the set driven key editor. You'll see that the values become orange in the channel box, this means that they are keyed:


Now do the same with all the other constraints. Make sure that you put the same attribute to 0 and 1 in each constraint.

Now select the control curve again and put the IK_FKswitch attribute to 10:


Select the upper constraint again in the set driven key editor and switch the 1 and the 0 in the bottom two attributes in the channel box, select the bottom two attributes in the right field of the driven section of the set driven key editor again and press key again:


Do the same for all the other selected constraints.

If you now select the lFootControlCurveIK and you set the value of IK_FKswitch to 0 and you move the lFootControlCurveIK you see that both the IK leg and the 'result' leg follow the movement. If you now rotate one of the FK control curves you see that nothing happens. The influence of the IK leg is maximal and the influence of the FK leg is 0. If you now select the lFootControlCurveIK again and put the IK_FKswitch attribute to 10 you see that the 'result' leg does have the rotation of the FK leg but doesn't follow the IK leg. Now the influence of the IK leg is 0 and the influence of the FK leg is maximal. If you put the IK_FKswitch of the lFootControlCurveIK on a value in between, 3 for instance, you will see that the leg is also placed somewhere in between and that the leg responds more to the IK leg. That's because the IK leg and FK leg both partially influence the position of the leg:


Creating a group based reverse foot

Now we have created a leg that responds to both Inverse Kinematics and Forward Kinematics, so now we want to have a bit more control over the foot. When creating a walking cycle or when letting the character do more than just walking we want to make the foot tap its toes, twist the toes, twist the heel, peel its heel and stand on its tip. We are going to do this by creating smart groups. But before you start, make sure this is present: an IKrp handle between hip and ankle, an IKsc handle between ankle and ball and an IKsc handle between the ball and toe.

First we will create our groups, it's easiest to do this in the hypergraph (window > hypergraph hierarchy):

Select the ankle IK and group it by going to edit > group (shortcut: ctrl+G):


Name this group lPeelHeelGroup. Pointsnap the pivot of this group to the ball joint of your IKleg (detach the pivot by pressing 'insert' on your keyboard, turn on pointsnap, move the pivot to the ball joint of the IKleg and re-attach it by pressing 'insert' again):


Now group the IK handle attached to the lToe and the one attached to the lBall of the IK chain together (in the hypergraph you can find it in the lFootControl hierarchy), name it lToeTapGroup and place its pivotpoint at the ball joint:


Select the lPeelHeelGroup and the lToeTapGroup, group them together, name this group lToePivotGroup and place its pivot at the toe joint:


Select the lToePivotGroup, group it again, name it lHeelPivotGroup and place its pivotpoint at the ankle joint:


Now we need to create switches that control these groups, we will do this by adding new attributes to the foot control. Basically the moving the foot like this has the properties of Forward Kinematics, but because we want to control the movement of the foot by using the lFootControlCurveIK, we will attach the new attributes to the lFootControlCurveIK.

To do this, select the curve and open its attribute editor. In the attribute editor, go to Attributes > add attributes.. You need to create 5 new attributes:

If you want to create more than 1 attribute you can press add instead of ok, in this way the add attribute menu will stay active.
attribute namedata typeminimummaximumdefault


Now you have to key certain values to these attributes by using the set driven key editor. We will begin with the peelHeel, to peel the heel we want the lPeelHeelGroup to rotate between 0 and 30 degrees (the amount of degrees depends on your character, if these values do not work for your character try other ones). Open the set driven key editor (Animate > set driven key > set..) and load the lFootControlCurveIK as the driver (select the curve and press load driver) and the groups we created as the driven (select the groups in the hypergraph and press load driven):


Select the peelHeel in the left field of the driver section of the set driven key editor, select the lFootControlCurveIK and put the peelHeel in the Channelbox at 0:


Now select the lPeelHeelGroup and the rotateX in the driven section of the set driven key editor and put the rotate X in the channelbox at 0:


Press Key to key it. You see the chosen channels turning orange. This means they are keyed.

Now select the lFootControlCurveIK and the peelHeel in the driver section of the set driven key editor again and change the peelHeel in the channelbox to 10.

Select the lPeehHeelGroup and the rotateX in the driven section of the set driven key editor and change the peelHeel in the rotate X to 30. Press key.

We can now peel the left heel by selecting the lFootControlCurveIK and replacing the peelHeel in the channelbox with a value between 0 and 10:


Before you start keying the rest of the attributes make sure that the peelHeel has been put back to 0.

Key the other 4 attributes in the same way but with different values:

lFootControlCurve - peelHeel0 to 10lPeelHeelGroup - rotateX0 to 30
lFootControlCurve - standTip0 to 10lToePivotGroup - rotateX0 to 40
lFootControlCurve - twistHeel-10 to 10lHeelPivotGroup - rotateY-50 to 50
lFootControlCurve - twistToe-10 to 10lToePivotGroup - rotateY-50 to 50
lFootControlCurve - toeTap0 to 10lToeTapGroup - rotateX0 to -50
These values are correct for this particular model. If your character moves better to other values feel free to use other ones.

After doing this you can move the foot by adjusting these values in the channelbox of the lFootControlCurveIK.


Do not put more than one of these values on something else than 0, your foot will do odd things.

The auto forearm twist

Create an IK handle between the shoulder and forearm and pole vector constrain it to a locator as is discussed in the section Inverse Kinematics for an arm. Now to be able to bend the elbow and still be able to rotate the wrist, we will need a control curve on the wrist, but made in a slightly different way then normal.

The beginning is the same: first create a nurbs circle by going to create > nurbs primitives optionbox and choose for the normal axis X before you press create. Pointsnap the circle to the wrist joint and orient constrain it to the wrist by selecting the wrist joint, then the circle and going to Constrain > orient:


Delete the orient constraint from the circle in the hypergraph (window > hypergraph hierarchy) and create an empty group (a nullgroup) by selecting nothing and pressing ctrl + G on your keyboard. Pointsnap this group also to the wrist joint and orient constrain it to the wrist joint (select the wrist joint, then with shift pressed select the nullgroup in the hypergraph, then go to constrain > orient), and afterwards delete the orient constraint in the hypergraph from the group. Now parent the circle in the hypergraph to the null group by MMB dragging it in the hypergraph onto the null group:


Give the group and circle a convenient name like lWristControlGroup and lWristControlCurve.

So far you have been following the same steps as with the creation of control curves for the FKleg, but from here on you need to orient the wrist joint slightly different to the controlcurve than with the leg. First select the circle, then the wrist joint and go to constrain > orient optionbox and choose the Y and Z axis as constraint axes and press add:


Then select the circle again, and with shift pressed the forearm joint and go to constrain > orient optionbox again and now choose the X axis as constraint axis before pressing add:


Now select the IKhandle between the shoulder and forearm and go to evaluate nodes > ignore all:


Now select with the move tool the IKhandle and press insert to detach the pivot. Move the pivot to the wrist by using pointsnap:


Press insert to reattach the pivotpoint. Now go to your hypergraph and select the effector attached to the left shoulder joint (in our case this is effector 10 attached to lShoulder), detach its pivotpoint by pressing insert and also pointsnap its pivot to the wrist joint:


Press insert to reattach the pivotpoint and turn evaluate all nodes back on by going to modify > evaluate nodes > evaluate all:


Now go back to the hypergraph and parent the IKhandle to the wrist control curve (in our case to the lWristControlCurve) by MMB dragging the handle onto the controlcurve:


You can now move the arm by moving the control curve and also rotate the hand around all axes by rotating the control curve:


The auto forearm twist can also be used in combination with an IK/FKswitch.

Back to Skeletons

Overview of Maya topics

Maya main index

Personal tools