Inverse kinematics is now a common part of animation systems in games and is a topic that might cover a chapter on its own. In this recipe, we'll look at placing a character's feet in accordance to the ground below. This is useful where an animation would otherwise place them in the air or on sloped ground.
Normally, animations work according to forward kinematics; that is, when a bone near the root of the skeleton rotates, it affects the bones further down the chain. As the name implies, Inverse Kinematics starts at the other end.
Here, we strive toward a desired position for the tip of a chain of bones, and bones further up the chain try to align themselves to suit this.
The most straightforward implementation ...