Home > Articles

Character Inverse Kinematics

  • Print
  • + Share This

Creator of the community VR Template for UE4, Mitch McCaffrey, discusses techniques built into Unreal Engine for interpolating the user’s current pose from known information about the player’s location.

This chapter is from the book

VR allows players to inhabit a virtual character’s body, and thus replicating players’ real-world movements to their virtual characters can be an immersion multiplier if done right.

This chapter discusses techniques built into Unreal Engine for interpolating the user’s current pose from known information about the player’s location.

Introduction to Inverse Kinematics

As opposed to forward kinematics, where you define each bone’s rotation to get your desired output, inverse kinematics (IK) allows you to define an end effector goal and let the system interpolate what the bone rotations need to be to get to that goal.

Many VR headsets give you access to precise head tracking so you know exactly where the user’s head is in your virtual world. Without expensive motion capture equipment, however, you do not necessarily know where any other bone is (aside from hands in the case of motion controllers).

In these situations, inverse kinematics lets you extrapolate where the other bones in the skeleton are located because of the predictable way in which bones rotate. The simplest method of IK is two-bone IK (see Figure 7.1), because the bone rotation can be calculated analytically with some basic trigonometric identities; however, note that once a third dimension is introduced, as is the case in VR, there are an infinite number of possible solutions to a two-bone IK setup. To deal with this, Pole Vectors/Joint Targets are introduced. These allow developers to create a preference for how the bones move. In UE4, Joint Targets define a point in space that, along with the direction from the root bone to the IK target point, generates a plane (the normal of this plane is the cross product of these two directions). This plane is then used to simplify the IK problem back down to two dimensions.

Figure 7.1

Figure 7.1 Two-bone inverse kinematics. Because the bone lengths are known, the delta from the previous bone rotations can be calculated through trigonometric identities.

UE4 offers another method for inverse kinematics that comes out of the box. This is Forward and Backward Reaching Inverse Kinematics (FABRIK). Unlike the two-bone IK implementation, FABRIK does not restrict the number of bones that can exist in the inverse kinematic chain. To do this, FABRIK takes a slightly different approach: rather than being analytical, like two-bone IK, FABRIK must be calculated iteratively by traversing up and down the chain of bones and converging toward a solution.

FABRIK first sets the last bone in the chain to match the position of the end goal, then works its way back up the chain, moving each bone toward the solution while attempting to maintain the bone’s length and a straight line to the previous bone (see Figure 7.2). Once this loop reaches the very first bone, it will be moved out of place; however, because this is the root of the chain and shouldn’t move from its original position, the algorithm is then run again, this time in reverse (hence Forward and Backward IK). By default, in UE4 this process is repeated ten times, but this iteration count can be changed on any FABRIK node in an animation graph.

Figure 7.2

Figure 7.2 Forward and Backward Reaching Inverse Kinematics. 1: The initial bone state. 2: The end bone is moved toward the goal (yellow circle). 3–5: The next bone in the chain is then moved along the line connecting this bone to the previous bone while maintaining the initial bone length. 6: Because the root bone has been moved, it is moved back to its original position and the process is done in reverse.

  • + Share This
  • 🔖 Save To Your Account