Skip to main content

ST Pickup

Lets players pick up an object in VR and on desktop. Its position is synced for everyone, and the holder becomes the owner, so scripts on the object can change synced values while it is held. (In VRChat terms: VRC_Pickup and VRC_ObjectSync in one.)

Add it with Add Component → StageTime → ST Pickup. The object needs a collider.

Field
pickupablePlayers can pick it up
DisallowTheftOthers cannot take it out of the holder's hand
InteractionTextShown when a player points at it
UseTextShown while held, for the use button. Empty = no use action

Scripts on the same GameObject get OnPickup, OnDrop, OnPickupUseDown and OnPickupUseUp (Events). From scripts:

STPickup pickup = GetComponent<STPickup>();
if (pickup.IsHeld) Debug.Log($"Held by {pickup.currentPlayer.displayName}");
pickup.Drop(); // makes the local holder drop it

HandOver(other) swaps what the local player holds: called in OnPickup, the hand lets go of this pickup and holds other instead, on the next frame. A deck that hands out its top card or a rack that hands out tools works this way (see the Card deck example).

While a pickup is held, Unity takes it out of its parent; scripts still see it and its children as part of your world.

Players pick up with grip in VR, a left click on desktop, the right trigger (or LB) on a gamepad, or the hand button on mobile. Use is the trigger of the holding hand in VR, or a left click, right trigger or the mobile use button while holding. To drop, let go of the grip in VR, right-click on desktop, press B on a gamepad, or tap the mobile drop button.

On desktop, gamepad and mobile, players can also turn and push or pull a held pickup that keeps the pose it was grabbed in: hold the middle mouse button and move the mouse (scroll to push or pull), hold RB and use the right stick (D-pad up and down to push or pull), or turn on the mobile adjust button and swipe.

The Pickup colour example changes colour each time the holder presses use.

Physics​

Without a Rigidbody, a pickup stays where it is dropped. Add a Rigidbody for physics: its Is Kinematic and Use Gravity are kept, and a pickup that is not kinematic can be thrown and falls, rolls and collides the same for everyone (see ST Object Sync). From scripts:

pickup.Respawn(); // back to where it started
pickup.SetKinematic(true); // for everyone; needs a Rigidbody
pickup.SetGravity(false); // for everyone; needs a Rigidbody

How it works​

ST Pickup is the same setup as StageTime's own synced props (the guitar and microphones in the main venue): an XR grab interactable, a synced transform and a hover outline, configured for you.