Foot IK |
This topic discusses the TwoJointIKSolver. This IK solver can be used to control an arm or a leg.
This topic contains the following sections:
The Samples contain an example which demonstrates how to use the TwoJointIKSolver for foot placement. Here is a video of this sample:
The TwoJointIKSolver affects three bones of a character. In the example above: upper leg, lower leg and foot.
The first bone (upper leg) can rotate freely. The second bone (lower leg) is fixed to the first bone with a hinge joint (knee), which rotates around a single axis. The rotation angle can be limited.
(Note that upper leg and lower leg can each consist of several bones. The IK solver keeps the rotations of any intermediate bones constant.)
The orientation of the third bone (foot) can be kept constant by the IK solver, or it can be changed to match a certain target orientation. This can be used to properly place a foot on a sloped surface.
The IK solver requires the ground position and optionally the target orientation of the last bone as input. Typically, a ray-cast is made for each foot to determine the ground distance and the normal vector of the surface. The foot orientation can be derived from the normal vector.
One application of a foot IK solver is, obviously, to place the feet exactly on the ground to avoid hovering feet or feet penetrating the ground.
Another interesting application is to reduce "foot sliding". Foot sliding can appear when key frames are interpolated or when animations are blended: A foot should stay firmly on the ground, but instead it slides laterally over the ground. To avoid foot sliding we need to know in which animation frames the foot should stay on the ground. While these frames are playing, we use the foot IK to glue the foot to a certain position on the ground.
You can find more details in the example’s source code.