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.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour - Nested types
SwipeTracker
Constructors
| Member | What it is |
|---|---|
SwipeInteractionController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private bool needToReenterAfterInteract | If true, a hand that starts an interaction while inside is dropped and must re-enter before it counts. |
private IntEvent OnSwipeExecuted | Event raised when a hand leaves the trigger, with the swipe direction (1, -1, or 0 if it didn't move far enough). |
private Vector3 swipeDirection | Local swipe direction, normalized. |
private float swipeMinDistance | How far along the direction the hand must move to count as a swipe. |
private Dictionary<Rigidbody, SwipeInteractionController.SwipeTracker> swipeTrackers | Active trackers, one per hand rigidbody inside the trigger. |
Properties
1 private and internal property
Methods
5 private and internal methods
| Member | What 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. |