Skip to main content

HandGrip

A class in Root.Township, Alta.Character.

Curls a hand model's fingers around what it holds, and blends in finger tracking from the controller. Turns itself off on headless servers.

Constructors​

MemberWhat it is
HandGrip()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

13 private and internal fields
MemberWhat it is
private HandGripConfiguration configurationThe HandGripConfiguration with thumb setups, splay curve and grip timings.
private Coroutine coroutineThe running UpdateGrip, or null.
private float[] fingerProgressPer-finger curl from skeletal input (thumb first), set by SkeletalInput.
private HandGrip.GripFinger[] fingersThe five fingers, each a chain of joints that curl until they hit the held object.
private float gripTimeGrip blend from 0 (open) to 1 (fully gripped), driven by UpdateGrip.
private bool isChangedSet when the grip changes. Probably meant to skip unchanged frames, though LateUpdate doesn't check it.
private bool isGrippingBacking field for IsGripping.
private bool isLeftHandBacking field for IsLeftHand; flips curl sides for the left hand.
private bool isNextForcedSkeletalWhen set by ForceNextSkeletal, the next LateUpdate uses skeletal blending even with no finger curl.
private float nonThumbCurlSum of the four non-thumb finger curls. Above 0.8 the fingers follow skeletal input while gripping.
private float splaidLerpHow splayed the fingers are, from the configuration's curve over totalCurl.
private float totalCurlSum of all five finger curls from skeletal input.
private Transform wristWrist transform the finger chains start from.

Properties​

MemberWhat it is
ThumbConfiguration CurrentThumbConfiguration { get; }Thumb configuration for the current thumb position.
bool IsEnabled { get; set; }Whether finger poses are updated each frame.
bool IsGripping { get; set; }Whether the hand is gripping. Setting it to true starts a grip.
bool IsLeftHand { get; }True for the left hand.
bool IsSkeletalGripEnabled { get; set; }Whether tracked finger curl can add to the grip pose.
ThumbPosition ThumbPosition { get; set; }Where the thumb rests, which picks the thumb configuration.

Events​

MemberWhat it is
event UpdateHandler PostLateUpdateRaised after the fingers are posed each frame.

Methods​

MemberWhat it is
void ForceNextSkeletal()Makes the next frame use the tracked finger pose.
void SerializeGrip(Stream stream)Reads or writes each finger's grip pose. Reading starts the grip animation.
void SkeletalInput(float[] fingersProgress)Takes per-finger curl amounts (thumb first) from finger tracking.
void StartGrip()Curls each finger until it touches the held object and animates into that pose.
4 private and internal methods
MemberWhat it is
private void Awake()Disables the component on headless servers, so grips only animate on clients.
private void LateUpdate()Blends every finger between open, saved grip and skeletal input each frame, then raises PostLateUpdate.
private void OnDrawGizmos()Editor: draws each finger joint's collision box, red when it's touching something.
private IEnumerator UpdateGrip() (iterator)Coroutine that moves gripTime towards 1 while gripping and back to 0 after, using the configured durations.

Used in​

Members of other types that take, return or hold a HandGrip: