Skip to main content

LongHoldInteractable

A class in Root.Township, the global namespace.

Interactable that tells a short grab from a long hold. Used by CommunalStorage; the local client times the grip and tells the server which one happened.

Constructors​

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

Fields​

MemberWhat it is
Action<Interactor> onLongHeldCalled with the hand when a long hold completes, on the client and again on the server.
Action<Interactor> onShortHeldCalled with the hand when the grab ends as a short hold, on the client and again on the server.
3 private and internal fields
MemberWhat it is
private float distanceTriggerSquaredSquared distance the hand may move from where it grabbed before the hold ends as a short hold.
private float pickupDurationSeconds the grip must last to count as a long hold. Defaults to 0.5.
private MethodSyncStruct<LongHoldInteractable.InteractArguments> syncInteractMethod sync on SpawnPouch that sends hold results to the server.

Methods​

MemberWhat it is
override void Initialize()Creates the syncInteract method sync.
override void Interact(Interactor interactor)On the local client, starts GripTimer or GripTimerPouch depending on whether hard grab is already held.
5 private and internal methods
MemberWhat it is
private IEnumerator GripTimer(Interactor interactor, BooleanInput hardInteractProxy) (iterator)Client coroutine for a grab started with hard grab held: long hold if kept still for pickupDuration, short if released or moved.
private IEnumerator GripTimerPouch(Interactor interactor, BooleanInput hardInteractProxy) (iterator)Client coroutine for a grab started without hard grab: counts down only while hard grab is pressed, then reports long or short.
private void LongHeld(Interactor interactor)Fires onLongHeld and, on a client, sends it to the server.
private void ShortHeld(Interactor interactor)Fires onShortHeld and, on a client, sends it to the server.
private void SyncInteract(IPlayer player, Stream stream, LongHoldInteractable.InteractArguments arguments)Method sync carrying the hand and long or short hold. The server fires the matching callback if the hand belongs to the sender.

Used in​

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