|
Table of Contents
|
Part of World Components
VRC_Pickup Description
The VRC_Pickup component allows you to take any object and make it grabbable. When adding the VRC_Pickup component to an object it will automatically add a Rigidbody to the object if it didn't have one already. When used in combination with VRC_ObjectSync, its position will automatically be synced for all players and ownership of the object will automatically transfer to whoever picks it up.
Parameters
| Parameter | Description |
|---|---|
| Momentum Transfer Method | |
| Force - | |
| Impulse - | |
| Velocity Change - | |
| Acceleration - | |
| Disallow Theft | Whether or not another player can steal this object from your hands while you are holding it |
| Exact Gun | If the Orientation is set to Gun, this will be the transform used to orientate the pickup in your hand. You can use the pickup itself or a child object, and the orientation will be the same for Desktop and VR players. The orientation will be as follows: The X axis is forward and the Z axis is up. If a transform not-related to the pickup (not the pickup itself or a child) is used, the pickup will be offset in your hand based on its distance from the Exact transform [This is probably a bug]. If the Orientation is set to Gun but this transform is not specified, it will be offset according to the orientation it was picked up from instead [Need a canny for this eventually, would like to see this as a feature!] |
| Exact Grip | If the Orientation is set to Grip, this will be the transform used to orientate the pickup in your hand. You can use the pickup itself or a child object, however the orientation will be different for Desktop and VR players: For Desktop the X axis is down and Z axis is forward, and for VR the X axis is forward and the Z axis is up, but tilted 30 degrees downward on both axes. This means that compared to the Gun orientation, a Grip pickup will lean 90 degrees forward on Desktop and 30 degrees forward for VR. If a transform not-related to the pickup (not the pickup itself or a child) is used, the pickup will be offset in your hand based on its distance from the Exact transform [This is probably a bug]. If the Orientation is set to Grip but this transform is not specified, it will be offset according to the orientation it was picked up from instead [Need a canny for this eventually, would like to see this as a feature!] |
| Orientation | How should the object be held in the player's hand: |
| Any - The user can hold this object from any position along its collider | |
| Grip - The user will hold it in the orientation of the transform specified in Exact Grip, but will be rotated based on whether the user is on Desktop or VR (see Exact Grip above for details). This is useful for pickups like swords and flashlights that should be orientated forward for Desktop users but not for VR users | |
| Gun - The user will hold it in the orientation of the transform specified in Exact Gun. This is useful for pickups which must be orientated in a specific way for both Desktop and VR users, such as for a gun | |
| Auto Hold | Does the pickup require the user to hold down the grab button to continue holding the object: |
| Auto Detect - If the Orientation is set to Grip or Gun, then this will act as Yes. If the Orientation is set to Any, this will act as No | |
| Yes - The pickup will stay in the user's hand after letting go of the grab button (Note that this does not have an effect for Oculus Rift users, who need to continue holding the pickup manually). To let go, Desktop users must right click, VR users need to press the grab button again, and Oculus Rift users simply need to let go of the grab button. Note that this setting is required in order for OnPickupUseDown and OnPickupUseUp triggers to work | |
| No - When grabbing the pickup object, the pickup will only be held for as long as the grab button is held down | |
| Use Text | If the pickup is Auto Held, this is the tooltip that will appear whilst grabbing the pickup and is used to explain what pulling the trigger does. It will be "Use" by default, and if left blank it will also change to "Use" at runtime |
| Throw Velocity Boost Min Speed | How fast the object needs to move to be thrown The speed needs clarification. This depends on the method of throwing and whether in desktop or VR. Desktop can hold for 5 seconds to "build up" the throw and throw on release. They can also "fling" and get much higher speeds. |
| Throw Velocity Boost Scale | How much throwing should scale, higher = faster thrown while lower means slower throw speed |
| Pickupable | This value determines whether the object can be picked up or not. This can only be changed in game via animations |
Notes
- You can disable a pickup by either disabling its collider or by animating the Pickupable option in the VRC_Pickup component. If you disable the collider and the object is not kinematic (has gravity or physics) then you are required to have a child collider in order to prevent the object from falling through the world.
- If you have an Animator or Animation component on the same object as the pickup, then VRC_SyncAnimaton will automatically be added to your object. If you need to animate a local or unsynced pickup, you must put the Animator or Animation on a parent object. See this canny for details.
Triggers and RPCs
| Event | Description |
|---|---|
| OnPickup | When the object is grabbed |
| OnPickupUseDown | When the use button is held while the object is grabbed. Note that the pickup has to Auto Hold for this to work |
| OnPickupUseUp | When the use button is released while the object is grabbed. Note that the pickup has to Auto Hold for this to work |
| OnDrop | When the object is let go |
When using the SendRPC action with triggers, you can call a few methods on the pickup itself:
| RPC | Description |
|---|---|
| Drop | Calling this will drop the pickup. The broadcast type for this must be set to Local. If you do not know who is holding the pickup, you can uncheck "Use Player ID as Last" and set the value to -1 to make any player drop it |
| Play Haptics | Calling this will vibrate the controller for the player holding the pickup |
Selection Highlight
Similar to VRC_Trigger's OnInteract, Pickups will highlight with the same rules:
- All enabled Mesh Renderers on the object or on children of the object will be used to make the Highlight. If any of them are marked as batching static, they will be ignored.
- Skinned Mesh Renderers cannot be used for Highlights. If your object is a Skinned Mesh, either switch to using a Mesh Filter with a Mesh Renderer or use a Mesh Collider to fake the Highlight instead. Note that when using a Mesh Collider, you cannot use the Is Trigger option unless it is set to Convex, which will ruin your shape. For these cases you can set the Layer to Player or Walkthrough in order to make it non-solid.
- If no Mesh Renderers are found, any colliders on the same object will be used instead. If there are multiple colliders on the same object as the Interact, whichever one is higher up on the inspector list will be used for the highlight. However, all of them can still be used to activate the Interact even if they don't highlight. Conversely, any colliders on children of the Interact object are completely ignored when it comes to both highlighting and interacting.
Setup Guide
In order to have a pickup, it is only required to have 3 components on the same GameObject: VRC_Pickup, Rigidbody, and a collider. Everything else is optional.
It is recommended that you use primitive colliders (Sphere, box, capsule) instead of mesh colliders, for performance reasons. Also, Unity will throw an error if you try to have a non-convex MeshCollider on a non-kinematic Rigidbody.
You do not need to have the pickup's renderer on the same GameObject as the VRC_Pickup component. You can have it as a child object. Having the visuals as a child will help orient and align the collider if it needs to be in a specific location, such as a handle.
By default, pickups will not be synced between players, meaning that one player will pick up the object and another player will see their hand as empty and the pickup will not have moved from its original position. To have all players see the pickup behave the same, you will need to add VRC_ObjectSync and keep the Synchronize Physics option checked.