Skip to main content

HandGestureController

A class in Root.Township, the global namespace.

Hand extension that drives the hand animator from grip and gesture input and syncs it to other players. It handles preset gestures, a gradual grip, and free finger tracking when the controller has a skeleton.

Constructors​

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

Fields​

MemberWhat it is
static AccumulativeAverageCount prepareForWriteTimerStatic profiling timer for PrepareForWrite.
static AccumulativeAverageCount serializeTimerStatic profiling timer for Serialize.
16 private and internal fields
MemberWhat it is
private HandCollisionsController collisionsControllerHandCollisionsController on the same object, if any.
private HandGestureDefinition currentGestureGesture now being shown.
private GestureMap gestureMapMap from thumbstick direction to gesture, plus the idle gesture.
private int gestureParameterIDAnimator hash for the Gesture parameter.
private int grabParameterIDAnimator hash for the Grab parameter.
private float gripAxisCurrent grip amount, 0 to 1, from input or the network.
private const int GripAxisNetworkingSectionsGrip is split into 32 steps; a change of step triggers a network write.
private static int GripNetworkingBitsBits used per grip or finger value (5, from the 32 steps).
private const float GripSectionSizeSize of one grip step (1/32).
private bool hasCollisionControllerWhether collisionsController was found.
private bool isFreeGestureModeTrue when free gesture mode is on in settings and the controller reports a skeleton.
private static Logger loggerNLog logger; logs failures in PerformGradualGrip.
private const int MaxNumberOfGesturesHighest gesture index sent over the network (15).
private HandGestureDefinition previousGestureLast gesture sent, to detect changes.
private int previousGripSectionLast grip step sent, to detect changes.
private float[] skeletonInputCurl values for the five fingers in free gesture mode.

Properties​

MemberWhat it is
HandGestureDefinition OverrideGesture { get; set; }Gesture forced on the hand, bypassing input; NoGesture means no override.
3 private and internal properties
MemberWhat it is
private int Alta.Networking.INetworkSerialized.MaximumBits { get; }Fixed bit budget of 32 for this component's network data.
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; }Shared timer for profiling PrepareForWrite.
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; }Shared timer for profiling Serialize.

Methods​

MemberWhat it is
override void InitializeControllerExtension()Enables the component once the controller is ready.
void PerformGesture(HandGestureDefinition gesture, bool isUpdatingCollisions = true)Sets the animator gesture on clients and updates hand colliders for the gesture if it changed.
protected override void Awake()Finds the collisions controller, caches animator parameter IDs, sets the idle gesture and disables itself until initialized.
12 private and internal methods
MemberWhat it is
private HandGestureDefinition GetCurrentGesture()Returns the gesture mapped to the thumbstick direction while the gesture action is held, otherwise idle.
private void HandleRemoteGesture()Remote hands: plays the received gesture, or applies the received grip amount.
private void Alta.Networking.INetworkEntityBehaviour.Initialize()Empty.
private void Alta.Networking.INetworkEntityBehaviour.InitializeAsServer(SpawnData data)Empty.
private void Alta.Networking.INetworkEntityBehaviour.OnConnected(Player player)Empty.
private void Alta.Networking.INetworkEntityBehaviour.OnDisconnected(Player player)Empty.
private void PerformGradualGrip(float gripAxis)Applies the idle gesture and sets colliders from the grip amount, or turns them off while holding something or dead.
private bool Alta.Networking.INetworkSerialized.PrepareForWrite(bool isWriteFull)Returns true when the gesture or grip step changed, or on a full write.
private void Alta.Networking.INetworkSerialized.Serialize(Stream stream, bool isWriteFull)Writes or reads the gesture index, free mode flag, and either five finger values or the grip amount.
private void Update()Each frame: applies OverrideGesture if set, otherwise local input or remote state.
private void UpdateAnimatorEnabled(bool isEnabled)Turns the hand animator on or off if it isn't already.
private void UpdateLocalGesture()Local hand: uses finger tracking in free gesture mode, otherwise a thumbstick gesture or the grip axis.

Used in​

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