Skip to main content

PullPickup

A class in Root.Township, the global namespace.

A stand-in pickup that forwards grabs to a target item and hands it over when pulled far enough in a set direction. Used for buried items when digging. The server checks the pull.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private Transform cachedTransformThis object's transform, cached.
private bool isReleasingTargetOnPullIf true, the target stays released after the pull instead of being forwarded again.
private Coroutine pullCoroutineRunning CheckPull, or null.
private Vector3 pullDirectionLocal direction the hand must pull in.
private float pullDistanceBacking field for PullDistance, at least 0.05.
private PullEvent pulledOnClientEvent run on clients when pulled.
private PullEvent pulledOnServerEvent run on the server when pulled.
private MethodSyncStruct<bool> syncForwardMethod sync for the forward state.
private MethodSync syncPulledMethod sync for the pull.
private Interactable targetPickupThe interactable pulled free (for example a cork or a sword in a stone). While null, this pickup is disabled.

Properties​

MemberWhat it is
Pickup Pickup { get; }This entity's Pickup.
float PullDistance { get; set; }How far (local units) the hand has to move along the pull direction. Minimum 0.05.

Methods​

MemberWhat it is
override void Initialize()Sets up forwarding to the target (or disables the pickup with no target) and the sync messages.
void Pull(Interactor interactor = null)Releases the target: swaps the interactor's grab to it, or with no interactor pops it up and makes it physical. Then fires the pulled events.
void SetTargetPickup(Interactable targetPickup)Sets the target if none is set yet and starts forwarding its grabs to this pickup.
7 private and internal methods
MemberWhat it is
private IEnumerator CheckPull(Interactor interactor) (iterator)Server coroutine: while the hand holds this pickup, pulls once the hand has moved pullDistance along pullDirection.
private void HandleForward(bool isSettingForward)Starts or stops forwarding grabs of the target to this pickup. With isReleasingTargetOnPull, the server also makes the target save on its own.
private static void OffsetHandTargetForGrabAssist(Pickup pickup, Interactor interactor)Offsets the hand target when grab assist picks it up from more than about 0.3 m away.
private void OnDrawGizmosSelected()Draws the pull direction and distance in the editor.
private void StartCheck(Interactable interactable, Interactor interactor)Server: starts CheckPull when someone grabs this pickup.
private void SyncForward(IPlayer player, Stream stream, bool isSettingForward)Syncs whether grabs are forwarded; the server relays it to the chunk.
private void SyncPulled(IPlayer player, Stream stream)Syncs a pull; the server relays it and runs its event, clients free the target and play the pull event.

Used in​

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