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.
- Listed in Global namespace: E to H
- Inherits or implements
MonoBehaviour - Nested types
HandInteraction
Constructors
| Member | What it is |
|---|---|
HandInteractor() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
11 private and internal fields
| Member | What it is |
|---|---|
private Controller controller | The hand's controller. |
private Vector3 currentPosition | Hand position from the last fixed update. |
private bool isBeingDestroyed | Set in OnDestroy so tracking is not restarted. |
private Vector3 lastPosition | Smoothed earlier position used for MoveDirection. |
private float lerpSpeed | How fast the last position catches up to the current one. |
private static Logger logger | Class logger. |
private float maxDistanceSquared | Max squared movement for a match, so spawning or teleporting does not trigger sounds. |
private HandInteractor.HandInteraction[] possibleInteractions | The hand interactions to test on contact. |
private Collider trigger | Trigger collider, only on while the hand is free. |
private IUnityUpdateMethod update | Registered fixed update method while tracking. |
private static UpdateModule updateModule | Shared fixed update module for all hand interactors. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
void Reset() | Sets the last position to the current one, zeroing MoveDirection. |
7 private and internal methods
| Member | What 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: