Skip to main content

HandInteractor

A class in Root.Township, the global namespace.

Client: detects hand to hand gestures like high fives or fist bumps when two empty hands' triggers meet, and plays their effects and sound. Off on the headless server.

Constructors​

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

Fields​

11 private and internal fields
MemberWhat it is
private Controller controllerThe hand's controller.
private Vector3 currentPositionHand position from the last fixed update.
private bool isBeingDestroyedSet in OnDestroy so tracking is not restarted.
private Vector3 lastPositionSmoothed earlier position used for MoveDirection.
private float lerpSpeedHow fast the last position catches up to the current one.
private static Logger loggerClass logger.
private float maxDistanceSquaredMax squared movement for a match, so spawning or teleporting does not trigger sounds.
private HandInteractor.HandInteraction[] possibleInteractionsThe hand interactions to test on contact.
private Collider triggerTrigger collider, only on while the hand is free.
private IUnityUpdateMethod updateRegistered fixed update method while tracking.
private static UpdateModule updateModuleShared fixed update module for all hand interactors.

Properties​

MemberWhat it is
bool IsInteracting { get; private set; }Whether the hand's interactor is busy with something.
Vector3 MoveDirection { get; }How far the hand moved from its smoothed last position, used as speed and direction.
PlayerController Player { get; private set; }The player controller this hand belongs to.

Methods​

MemberWhat it is
void Reset()Sets the last position to the current one, zeroing MoveDirection.
7 private and internal methods
MemberWhat it is
private void Awake()Turns the trigger off until the hand is free.
private void EndedInteraction(Interactor interactor, Interactable interactable)When the hand stops holding or using something, turns the trigger on and starts tracking movement.
private void OnDestroy()Stops the update and marks the hand as being destroyed.
private void OnTriggerEnter(Collider other)When another free hand touches this one, checks each possible interaction and resets both on a match.
private void Start()Client: finds the player and hooks the interactor's start and end events.
private void StartedInteraction(Interactor interactor, Interactable interactable)When the hand starts an interaction, stops tracking and turns the trigger off.
private void UpdateDistance()Fixed update: lerps the last position toward the current one.

Used in​

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