Skip to main content

SwipeInteractionController

A class in Root.Township, the global namespace.

Trigger that detects a player's hand swiping through it along a set direction and raises OnSwipeExecuted with 1, -1 or 0 when the hand leaves.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private bool needToReenterAfterInteractIf true, a hand that starts an interaction while inside is dropped and must re-enter before it counts.
private IntEvent OnSwipeExecutedEvent raised when a hand leaves the trigger, with the swipe direction (1, -1, or 0 if it didn't move far enough).
private Vector3 swipeDirectionLocal swipe direction, normalized.
private float swipeMinDistanceHow far along the direction the hand must move to count as a swipe.
private Dictionary<Rigidbody, SwipeInteractionController.SwipeTracker> swipeTrackersActive trackers, one per hand rigidbody inside the trigger.

Properties​

1 private and internal property
MemberWhat it is
private Vector3 SwipeDirection { get; }The swipe direction in world space (the local swipeDirection rotated by this transform).

Methods​

5 private and internal methods
MemberWhat it is
private void OnDestroy()Stops and clears all swipe trackers.
private void OnDrawGizmosSelected()Draws the swipe direction and minimum distance as a red line.
private void OnTriggerEnter(Collider other)Starts tracking a rigidbody that belongs to a Controller (a hand).
private void OnTriggerExit(Collider other)When the last collider of a tracked hand leaves, stops tracking and raises OnSwipeExecuted.
private void RemoveRigidbody(Rigidbody rigidbody)Drops a hand's tracker without raising the event.