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.
- Listed in Global namespace: E to H
- Inherits or implements
ControllerExtension,INetworkSerialized,INetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
HandGestureController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static AccumulativeAverageCount prepareForWriteTimer | Static profiling timer for PrepareForWrite. |
static AccumulativeAverageCount serializeTimer | Static profiling timer for Serialize. |
16 private and internal fields
| Member | What it is |
|---|---|
private HandCollisionsController collisionsController | HandCollisionsController on the same object, if any. |
private HandGestureDefinition currentGesture | Gesture now being shown. |
private GestureMap gestureMap | Map from thumbstick direction to gesture, plus the idle gesture. |
private int gestureParameterID | Animator hash for the Gesture parameter. |
private int grabParameterID | Animator hash for the Grab parameter. |
private float gripAxis | Current grip amount, 0 to 1, from input or the network. |
private const int GripAxisNetworkingSections | Grip is split into 32 steps; a change of step triggers a network write. |
private static int GripNetworkingBits | Bits used per grip or finger value (5, from the 32 steps). |
private const float GripSectionSize | Size of one grip step (1/32). |
private bool hasCollisionController | Whether collisionsController was found. |
private bool isFreeGestureMode | True when free gesture mode is on in settings and the controller reports a skeleton. |
private static Logger logger | NLog logger; logs failures in PerformGradualGrip. |
private const int MaxNumberOfGestures | Highest gesture index sent over the network (15). |
private HandGestureDefinition previousGesture | Last gesture sent, to detect changes. |
private int previousGripSection | Last grip step sent, to detect changes. |
private float[] skeletonInput | Curl values for the five fingers in free gesture mode. |
Properties
| Member | What it is |
|---|---|
HandGestureDefinition OverrideGesture { get; set; } | Gesture forced on the hand, bypassing input; NoGesture means no override. |
3 private and internal properties
| Member | What 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
| Member | What 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
| Member | What 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: