Setting up inverse kinematics (IK) for user avatars in VR
Task – take three data points (head, left hand, right hand) and from them create convincing body. This is Full Body IK for VR-avatar: three tracking points from headset and controllers must drive entire skeleton so avatar looks alive, not wooden mannequin with arms in right positions.
This is surprisingly non-trivial task.
Three data sources and what to do with them
From headset arrives: XRNode.Head (HMD position and rotation), XRNode.LeftHand, XRNode.RightHand. From head position and arm positions must recover pelvis position, spine, shoulders, elbows, legs.
Pelvis – approximated from head position with fixed offset downward. Problem: when player leans, this offset works incorrectly – pelvis "floats" forward unnaturally. Correct solution – smooth pelvis position relative to head movement history and use secondary heuristic: if head position height decreased by X cm – player crouched, shift pelvis down and forward.
Shoulders – recovered from head rotation and hand positions. If head turned right and right hand raised – right shoulder should rise, left fall. This realized through ChainIK or TwoBoneIK + MultiRotationConstraint in Unity Animation Rigging.
Elbows – most complex part. Two known points (shoulder and wrist) give infinite elbow solutions. Needed pole target: virtual point toward which elbow "pulls." Standard solution – pole target computed from horizontal projection of forearm with down-back bias. In XR Interaction Toolkit with Animation Rigging – TwoBoneIK Constraint with explicit Hint Target.
Implementation in Unity Animation Rigging
Package com.unity.animation.rigging version 1.1+ – standard for this task in Unity. Rig structure for VR-avatar:
-
Rig Builderon character root -
Rigobject with several Constraint components -
TwoBoneIKfor each arm: Source – wrist bone, Target – VR controller transform, Hint – pole target -
MultiParentConstraintfor neck/head: driven by HMD transform -
ChainIKfor spine: from pelvis to chest, weight managed by torso tilt -
TwoBoneIKfor legs (if foot IK needed on uneven surfaces)
Important nuance: rig weight system. Each Constraint has Weight from 0 to 1. During smooth transitions – for example, when player puts down weapon and enters locomotion – weights interpolated in code to avoid abrupt pose switch.
Problems encountered in production
Flickering at boundary poses. When player's arm goes behind back or raises above head, TwoBoneIK transitions to singular position – fully extended chain without unique solution. Avatar jerks. Solution – clamp extension angle: forbid TwoBoneIK fully extending (maximum angle 170° instead of 180°).
Hand desynchronization at high latency. If avatar renders in LateUpdate or with delay, arms lag real controllers. Avatar hands must update in OnBeforeRender or via XR Interaction Toolkit's late binding mechanism.
Calibration for player height. Head-to-pelvis offset not universal: 1.90m and 1.60m persons – different proportions. Proper implementation has calibration routine: player stands straight, presses button, system measures current HMD height and recalculates all offsets.
Timeline for setting up Full Body IK for VR-avatar: 3 to 7 business days depending on rig complexity and behavior requirements. Cost calculated individually.





