Hand
A class in Root.Township, Alta.Character.
One hand of a player's character: links the controller, IK hand target, grip animator and ghost hand, and handles where held items attach. A component under each Controller; set up by SetupWithController.
- Listed in Players and characters
- Inherits or implements
CharacterComponentController
Constructors
| Member | What it is |
|---|---|
Hand() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
19 private and internal fields
| Member | What it is |
|---|---|
private CharacterComponentControllerCollection armIKControllers | The arm IK controllers for this hand. |
private Controller controller | Backing field for Controller, found in the parents on first use. |
private ControllerOffsetSettings controllerOffsetSettings | Per-platform controller offsets for each hand. |
private HandGestureController gestureController | Backing field for GestureController. |
private GhostHandController ghostHandController | The ghost hand shown when the real hand is held back from the controller. |
private HandGrip gripAnimator | The HandGrip that animates the fingers. |
private TransformSave gripPointSave | The grip point's original transform, saved on setup and restored by Detach and MoveGripPoint. |
private Animator handAnimator | The hand's Animator. |
private HandIndex handIndex | Whether this is the left or right hand. |
private TransformSave handTargetSave | The IK hand target's original transform, saved on setup and restored by Detach. |
private HandTargetHandler ikHandTarget | The IK hand target, used by the controller to measure distance to the ghost hand. |
private bool isNotFixingIKHandToPickup | When set on the prefab, skips hooking the detach and centre of mass handlers whatever HandSettings says. |
private static Logger logger | Logger for this class. |
private MasterHand masterHand | The MasterHand with the IK and master hand roots. |
private bool movedPickupInThisFrame | Unused in this build. |
private TransformSave pickupStateBeforePhysics | Unused in this build. |
private PlayerMode platform | The platform the hand was set up for. In the editor, Meta Quest is treated as OpenXR. |
private Vector3 savedCenterOfMass | The pickup's centre of mass before this hand moved it, restored on release. |
private HandShakeOffDetector shakeDetector | Detects the hand shaking things off; exposed as ShakeDetector. |
Properties
| Member | What it is |
|---|---|
CharacterComponentControllerCollection ArmIKControllers { get; } | The arm IK controllers for this hand. |
float ArmLength { get; } | Arm length from the player's hand settings. |
float ArmLengthSquared { get; } | ArmLength squared. |
Controller Controller { get; private set; } | The Controller this hand belongs to, found in its parents if not set. |
float DistanceToMasterHand { get; } | Distance between the IK hand root and the master hand root, so probably how far the visible hand lags behind the tracked one. |
HandGestureController GestureController { get; } | The hand gesture controller extension on this hand's controller. |
GhostHandController GhostHandController { get; } | The ghost hand controller for this hand. |
HandGrip GripAnimator { get; } | The grip animator; its transform gets the per-platform controller offset. |
Animator HandAnimator { get; } | The hand's animator. |
Transform HandIKTarget { get; } | The transform the arm IK reaches for. |
HandIndex HandIndex { get; } | Left or right. |
Transform IKWrist { get; } | The IK hand root (wrist) transform. |
Interactor Interactor { get; } | The controller's interactor, which grabs things. |
bool IsAlwaysRenderingPickupAtIKHand { get; set; } | Whether held items are always drawn at the IK hand. Copied from hand settings at setup. |
Vector3 LastGrabOffset { get; set; } | Grab point in the held pickup's local space, set when it is grabbed. Used for the centre of mass. |
Vector3 LastGrabOffsetRelativeToWrist { get; set; } | Grab offset relative to the wrist, set when grabbing. |
Quaternion LastGrabRotation { get; set; } | Grab rotation relative to the pickup, set when grabbing. |
Quaternion LastGrabRotationRelativeToWrist { get; set; } | Grab rotation relative to the wrist, set when grabbing. |
Joint LastJoint { get; set; } | The joint made by the last grab. |
MasterHand MasterHand { get; } | The MasterHand that maps the tracked hand onto the IK hand. |
Hand OtherHand { get; } | The player's other hand. |
TransformSave SavedGripPoint { get; } | The grip point's transform saved at setup. |
TransformSave SavedHandTargetPoint { get; } | The IK hand target's transform saved at setup. |
HandShakeOffDetector ShakeDetector { get; } | The shake-off detector for this hand. |
float SqrDistanceToMasterHand { get; } | Squared DistanceToMasterHand. A Lock uses it to pull a key out. |
1 private and internal property
| Member | What it is |
|---|---|
private HandSettings Settings { get; } | The player's HandSettings, from PlayerSettings. |
Methods
| Member | What it is |
|---|---|
void AttachTo(Vector3 wristPosition, Quaternion wristRotation, Transform parent) | Parents the IK hand target to a transform at a given wrist position and rotation, so the visible hand sticks to it. |
void AttachToInPlace(Transform parent) | Attaches the IK hand target to a transform where the IK wrist is now. |
static void AverageCenterOfMass(Pickup pickup, CenterOfMassSetter centerOfMass) | Sets a pickup's centre of mass to the average grab offset of all hands holding it. |
void Detach() | Puts the grip point and IK hand target back where they were saved at setup. |
void MoveCenterOfMassToGripPoint(Interactor interactor, Interactable interactable) | Moves a grabbed pickup's centre of mass to the grab point, or averages it when held by more hands. Skips pickups that override it. |
void MoveGripPoint(bool isToMaster) | Moves the controller's grip point under the master hand root, or back to its saved parent. |
void OffsetHandTarget(Vector3 worldSpacePosition) | Moves the IK hand target to a world position. |
void SetupWithController(Controller controller) | Links the hand to its controller, applies the platform's controller offset, saves the start transforms and hooks grab events. |
void UpdateWithCustomOffset(SerializableTransform offset) | Reapplies the platform controller offset plus an extra offset. |
4 private and internal methods
| Member | What it is |
|---|---|
private void Detach(Interactor interactor, Interactable interactable) | Puts the grip point and IK hand target back where they were saved at setup. |
private void ResetCenterOfMass(Interactor interactor, Interactable interactable) | When a hand lets go, restores the pickup's centre of mass (or removes a temporary setter), or averages the remaining hands' grab points. |
private void SetUpForPlatform() | Works out the hand's platform (local player mode or the network player's) and applies its controller offsets. |
private void UpdateControllerOffsets(SerializableTransform additionalOffset = null) | Moves the grip animator to the platform's controller offset, plus any extra offset. Throws if no offset exists for the platform. |
Used in
Members of other types that take, return or hold a Hand: