Skip to main content

DragTrigger

A class in Root.Township, the global namespace.

Trigger that builds up a drag offset from a solid collider moving through it, and lets it ease back when nothing touches it. Read DragPull.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private Collider currentDraggerUnused field; CurrentDragger is an auto property.
private AltaCoroutine dragUpdaterThe running drag update coroutine.
private HashSet<Collider> intersectingCollidersColliders inside the trigger.
private float maxDistanceDropoffExponent that slows the ease back as the pull gets small.
private float maxDragDistancePull size below which easing back slows down.
private float maxDragSpeedMost the pull can change per second.
private Vector3 oldDraggerPositionDragger position on the last frame.

Properties​

MemberWhat it is
Vector3 DragPull { get; private set; }Total drag offset built up so far. It eases back to zero when nothing drags.
1 private and internal property
MemberWhat it is
private Collider CurrentDragger { get; set; }The collider currently dragging.

Methods​

5 private and internal methods
MemberWhat it is
private void OnDestroy()Stops the drag update coroutine.
private void OnTriggerEnter(Collider other)Adds a solid collider that has no DragTrigger of its own.
private void OnTriggerExit(Collider other)Removes the collider and clears it if it was dragging.
private void Start()Starts the drag update coroutine.
private IEnumerator UpdateDragPull() (iterator)Each frame, adds the dragger's movement to DragPull (speed capped), or eases it back when none.

Used in​

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