Skeleton Animation Manual

CCD IK + IK-Constraint 

CCD (cyclic coordinate descent) IK is a simple and effective algorithm to solve the IK problem.

CCDIK1

The enable/disable of CCD IK is controlled by the button "New IK Sys Disabled" in above image.

Clicking it will toggle between the "CCD IK" & "default IK". (New IK means the CCD IK)

The control method of CCD-IK is the same as the default IK, what makes the difference is the ability to apply IK-constraints.

IK-Constraints could significantly improve the result quality, e.g.: limit elbow/knee to rotate along a fixed axis.

IK-constraints are in the form of standard MonoBehaviours, so it can be added on the joint like any other behaviours; 

NOTE: Unity's built-in IK solver only apply on limbs of Humanoid models, the IK-solver mentioned here can be applied on any skeleton hierarchy and any length of bone-links.

Angle Constraints

Angle constraint is to limit the joint to only rotate along ONE axis. You could also define the valid range of the rotation angle.

AngleConstraint

(1.1) Setup
Just add the component, if the joints are not colinear, all the things will be setup automatically.

The red axis: the rotation axis, which the joint will rotate around
The green axis: the primary axis, which points the direction of 0 degree.

* What if the red-axis is pointing wrong direction?
The red-axis is supposed to be perpendicular to the two bones linked to this joint. But if the two bones are in the same line, the red axis could get the wrong result.
In such case, just rotate the forearm inward a little and click the "ReInit" button, 

(1.2) Fields intro

  • Enabled: if this toggle is unchecked, IK solver will not try applying this constraint;
  • nextJoint: usually, this is auto-set to the first child of the joint transform, you could change it if necessary.
  • ReInit: clicking this button will trigger calculation of all parameters.
  • Angle Limits: limit the valid range of angles when rotate around the "Rotation Axis", ([-180f, 180f], LHS)
  • Rotation Axis: in 95% cases, you should not change it by hand, just click the ReInit button after rotate the child bone and let the editor to calculate the cross-product for you
  • Primary Axis: in 95% cases, you don't need to change it by hand, this axis by default is in the same direction of the parent bone;
  • Display Settings: some gizmos settings, the changes made here are only valid in one Unity session. You could make permanent changes in the "Edit/Preferences/Skele" settings;

(1.3) Remark

About Angle Limits, it should be <-135, 0> for elbow and knee joints in usual case, 

 

Once the IK-constraints are setup, they will take effect if the owner GameObject lies on the current IK-link.

Be noted that, the IK-constraints only work with the CCD-IK, not the default-IK;

CCD-IK & IK-Constraints can be setup & used in runtime too, we will cover that part in the "Constraint System" document category.