Skip to main content

MultiHandPickup

A class in Root.Township, the global namespace.

A pickup that needs several hands (2 or more) to lift, such as a heavy log. With fewer hands, each grab stays loose and lets go if the hand pulls too far away.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Dictionary<Interactor, Coroutine> distanceCheckCoroutineRunning CheckDistance coroutine per hand.
private bool isCreatingJointsTrue while CreateJoint is joining all hands, so the inner calls take the normal path.
private float maxDistanceToReleaseSquaredSquared distance between real and ghost hand that makes a loose grab let go.
private int minHandsToPickupHands needed to lift it (at least 2).
private MethodSync syncVelocityMethod sync for the speed at release.

Properties​

MemberWhat it is
override int InteractorsToRelease { get; }Returns minHandsToPickup.

Methods​

MemberWhat it is
override void FinishInteraction(Interactor oldInteractor)When a release leaves one hand too few, drops and regrabs the remaining hands so they go back to the loose state.
override void Initialize()Creates the velocity sync.
override void Interact(Interactor interactor)Keeps the body kinematic while fewer than minHandsToPickup hands hold it.
override void NetworkStopInteraction(InteractArguments arguments, Interactor interactor, Action<Interactable> handleInteractionEnd)Ends the interaction and, if enough hands were holding, applies the networked position, rotation and speed.
protected override void AddSecondaryCollision()Adds the secondary collision check only once enough hands hold it and the last holder is the local player.
protected override void CreateJoint(Interactor newInteractor)Holds off on real joints until minHandsToPickup hands grab, then joins all of them at once. Extra hands join normally.
2 private and internal methods
MemberWhat it is
private IEnumerator CheckDistance(Interactor interactor) (iterator)Local coroutine for a hand that can't lift it yet: lets go once the real hand is too far from the ghost hand.
private void SyncVelocity(IPlayer player, Stream stream)Sends the body's speed and spin. The server forwards it to other players.