Look-At IK Solver |
This topic discusses the LookAtIKSolver.
This topic contains the following sections:
The Samples contain an example which demonstrates how to use the LookAtIKSolver. Here is a video of this sample:
The look-at IK solver influences a single bone. The bone is rotated to look at a certain target position. Often it is only used to rotate the "head" bone of the model. But you can also apply several look-at IK solvers to a whole bone chain to create a more natural animation.
In the video, look-at IK solvers are used for the head bone, the neck bone and several spine bones. All bones will try to look at the target. The character does not only rotate the head, it will also bend and rotate the upper torso.
Each IK solver has a Weight property, which can be used to reduce the IK solver’s influence. The solver for the head bone uses a weight of 1. The other solvers use a gradually lower value. This means, the head will look directly at the target; the other bones show a more subtle motion.
Depending on the animated model, the results of the look-at IK can appear weird for certain target positions. Test which target locations look okay and keep the look-at target in this range. For example: Often, you want to avoid target positions that are very close to the head, very low on the ground, very high in the air or directly behind the character.
The look-at IK solver has a Limit property where you can define the max angle of the rotation.
Sometimes the character head "snaps" to a new position. This happens when the IK solver is switched on, when the target position is set to a whole new position, or when the target is at an extreme position (e.g. directly behind the head). To avoid this, you can slowly fade-in the weight of the IK solver, or you can use an artificial target position that slowly transitions to the actual target position. (Of course, you can use the animation system to create a fade-in animation that controls the weight or an animation that changes the target position!)
You can also dynamically adjust the solver weights if poses appear strange. For example, the model in the video looks natural when it bends down to look at the ground. But bending back to look into the sky creates an unnatural pose. In this case the weight of the spine bone IK solvers can be reduced when the target is above eye height.
The look-at IK solver example from the video is one of many examples that come with the DigitalRune Engine. You can find more details in the example’s source code.