IKRig.component
This package holds more than this page lists. See all of its files in its world.
README.md
IKRig
Whole-character IK on a humanoid: both legs, both arms, a look-at, and ground adaptation, resolved through the body's canonical roles so one configuration works on any humanoid mesh.
hero.component.add("IKRig", { grounding = true, rightHandTarget = ledgeRef, lookTarget = playerRef })
Everything registers on a single solve pass in a fixed order: grounding, then legs, then the lean and the look of the spine and head, then arms. Grounding leads because it moves the pelvis, and the pelvis is the root of every limb.
Fields
leftFootTarget,rightFootTarget,leftHandTarget,rightHandTarget, each with a matching…Weight.leftHandRotationWeight,rightHandRotationWeight— how far a hand bone takes the rotation of its hand target. The target's rotation is a palm: the frame whose -Z points along the fingers and +Y out of the back of the hand. The bone is laid on it by the rig's own frame for the hand, read from its rest pose, so any humanoid rig whose roles name its hand and fingers is turned the same way.leftFingers,rightFingers,leftFingerWeight,rightFingerWeight— the direction each finger bone points along, 45 numbers: for each finger (thumb, index, middle, ring, little) its three bones' unit directions in the palm's frame, x then y then z, and how far the finger bones take them. A bone is turned by the shortest arc from the animation's pose, so its twist stays the animation's. They take effect while the hand has a target and a weight.lookTarget,lookWeight,lookClampAngle,lookBodyWeight.headTarget,headWeight— a body that follows a head it does not animate (a person's head in a headset). The head bone reaches the target: the hips drop for a crouch (the legs bend to let them, so the feet need targets to stay planted) and shift toward a lean, and the spine run from the lowest spine bone to the head bends the rest of the way. The head's own turn is the look-at's.hipsTarget,hipsWeight— the hips themselves at a point, for a tracker worn at the waist. While it is set the hips come from it and the head's lean no longer moves them; the spine still bends to the head target.grounding— casts a ray under each foot, moves that foot's target to the surface, tilts it to the normal, and drops the pelvis far enough that neither leg over-reaches.groundingMaxSlope— how far a foot may tilt onto a steep face, in degrees.groundingFootHeight— how far the foot's origin sits above its sole.groundingHalfLife— smoothing on every value that comes off a raycast. Without it a ray crossing a step edge pops the foot between two heights.groundingRayUp,groundingRayDown— how far above and below the foot to cast.
An explicit foot target wins over the grounder. The grounder still counts that foot toward the pelvis drop, so planting one foot on a ledge while the other follows the terrain stays coherent.
Checking it
hero.component.get("IKRig"):rigState()
-- { ready, status, pelvisOffset, limbs, hands, lean, look, error }
limbs carries each resolved limb's weight, residual distance, ground contact
and lift. pelvisOffset is the current drop — roughly zero on flat ground
whether or not grounding is doing anything, so read the per-foot grounded
flags rather than the offset alone.
Climbing is a character controller's job. Grounding lowers the pelvis but never raises it, so a tall step asks a leg to stretch past its limit and the solve stops short.