Game Development Reference
In-Depth Information
9 Inverse kinematics
For many real-time applications the actions of the characters will be
created before the application is run and the interactive game code will
select the most suitable action for a particular stage of the game. This
provides an effective game style, but what happens when a character
needs to reach further than the stored action in order to pick up an item?
It would be good if the final position of the character's hand could be
determined just by providing a world location for the hand and letting the
code determine the orientations of the hand, forearm, bicep, shoulder,
torso and hips, that are needed to achieve this goal. Inverse Kinematics
(IK) provide this solution and can be a useful addition to any game code
engine. Anchoring feet or any other part of the character can be done
using IK solutions. If a character has a fall action that relies on falling on
a flat floor, but instead because of the game location the floor is uneven,
then IK can be used with collision detection to ensure that the character's
final position relates to the game location.
In this chapter we will look first at how IK developed out of robotics. In
the next section we will look at how to determine the orientation for a
single link and then a double link analytically. We will look at the problems
for calculating the position of an IK chain with more than two links.
Following on from the problems associated with analytical solutions, we
will look at how iterative or numerical solutions can be used to find IK
solutions for chains with more than two links. Finally, we will look at how
IK can be blended with forward kinematics so that pre-stored actions can
be used alongside IK solutions.
How IK developed out of robotics
The principle of an inverse kinematics solution to a motion problem is that,
given a position in world space and the end point of a linked chain (end
effector), determine the rotations that have to be applied to the linked