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.
- Listed in Players and characters
- Inherits or implements
MonoBehaviour - Nested types
GripFinger,GripJoint,ThumbGripJoint
Constructors
| Member | What it is |
|---|---|
HandGrip() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private HandGripConfiguration configuration | The HandGripConfiguration with thumb setups, splay curve and grip timings. |
private Coroutine coroutine | The running UpdateGrip, or null. |
private float[] fingerProgress | Per-finger curl from skeletal input (thumb first), set by SkeletalInput. |
private HandGrip.GripFinger[] fingers | The five fingers, each a chain of joints that curl until they hit the held object. |
private float gripTime | Grip blend from 0 (open) to 1 (fully gripped), driven by UpdateGrip. |
private bool isChanged | Set when the grip changes. Probably meant to skip unchanged frames, though LateUpdate doesn't check it. |
private bool isGripping | Backing field for IsGripping. |
private bool isLeftHand | Backing field for IsLeftHand; flips curl sides for the left hand. |
private bool isNextForcedSkeletal | When set by ForceNextSkeletal, the next LateUpdate uses skeletal blending even with no finger curl. |
private float nonThumbCurl | Sum of the four non-thumb finger curls. Above 0.8 the fingers follow skeletal input while gripping. |
private float splaidLerp | How splayed the fingers are, from the configuration's curve over totalCurl. |
private float totalCurl | Sum of all five finger curls from skeletal input. |
private Transform wrist | Wrist transform the finger chains start from. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event UpdateHandler PostLateUpdate | Raised after the fingers are posed each frame. |
Methods
| Member | What 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
Used in
Members of other types that take, return or hold a HandGrip: