Skip to main content

PullAway

A class in Root.Township, Alta.Mechanisms.

Lets a player pull an object a set distance by grabbing a fake interactable, then fires onPulled on the server (such as pulling a root out of the ground). The holding player's game decides when the pull counts.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private Rigidbody actualRootRigidbody moved with the hand, kinematic while held.
private float distanceSquaredSquared distance from the pull origin that counts as pulled.
private Interactable fakeInteractableThe interactable players grab.
private Coroutine gripCoroutineThe running CheckGrip coroutine.
private AnimationCurve hapticsPerDistanceRatioCurve from pull progress to haptic strength.
private float maxDistancePerSecondSpeed limit on how fast the object follows the hand; 0 for no limit.
private PlayerEvent onPulledPlayer event fired on the server when the object is pulled free.
private Vector3 originNot used in this class.
private float pulledHapticDurationHaptic length when pulled free (default 0.5 seconds).
private float pulledHapticStrengthHaptic strength when pulled free (default 0.4).
private Vector3 pullOriginLocal point the pull distance is measured from.
private bool releaseOnPullMakes the player let go once pulled free.
private MethodSyncStruct<uint> syncPullMethod sync (SyncA) from client to server for a pull.

Methods​

MemberWhat it is
override void Initialize()Creates the pull sync.
7 private and internal methods
MemberWhat it is
private void Awake()Hooks the fake interactable's grab and release.
private IEnumerator CheckGrip(Interactor interactor) (iterator)Coroutine that moves the root after the hand; for the local player, gives haptics and fires or sends the pull once past the distance.
private void ClearCoroutine()Stops the running CheckGrip coroutine.
private void EndTracking(Interactable interactable, Interactor interactor)On release, stops tracking and makes the root non-kinematic again.
private void OnDrawGizmosSelected()Editor: draws the pull origin and the pull distance sphere.
private void StartTracking(Interactable interactable, Interactor interactor)On grab, starts CheckGrip for that interactor.
private void SyncPull(IPlayer player, Stream stream, uint playerIdentifier)Sends the pulling player's identifier; the server fires onPulled for that player.