Table of Contents
Implementing the simple pickup components #
- Install Udon Sharp: Ensure the Udon Sharp package is installed in your Unity project. If it isn’t, You can add it from the package manager in the VRC Creator Companion
- Create or Select an Object: In Unity, either create the object you wish to make pick-up-able or select an existing object in your scene.
- Add VRC_Pickup Component: With the object selected, navigate to the Inspector panel and click on “Add Component.” Search for “VRC_Pickup” and add this component to your object.
- Customize VRC_Pickup Properties: The VRC_Pickup component offers customizable properties like “pickupable”, “proximityPickup”, “holdType”, and more. Ensure the “pickupable” property is checked so players can pick up the object.
- Add VRC_ObjectSync Component: This component syncs the object’s position and rotation across the network, allowing other players to see it being picked up and interacted with. Add this by clicking on “Add Component” again, searching for “VRC_ObjectSync,” and adding the component.
- Add a Collider: If your object doesn’t already have one, add a collider. Click on “Add Component,” search for the suitable collider type (e.g., “Box Collider,” “Sphere Collider,” etc.), and add it to your object. Ensure the collider covers the object’s bounds for easy player interaction.
- Test Your Setup: After building and uploading your VRChat world, the object you’ve set up should be pick-up-able by players in-game.
The VRC_Pickup component in VRChat is used to allow objects to be picked up and held. Here’s a technical guide on how to use it:
Requirements:
- Rigidbody
- Collider
Parameters:
- Momentum Transfer Method: This defines how the collision force will be added to the other object which was hit, using Rigidbody.AddForceAtPosition. Note: the force will only be added if ‘AllowCollisionTransfer’ is on.
- Disallow Theft: This parameter determines if other users are allowed to take the pickup out of someone else’s grip.
- Physical Root: This can be used if the root of the object is not on the same gameobject as this script, allowing for multiple pickup points on a single object.
- Exact Gun: The position object will be held if set to Exact Gun.
- Exact Grip: The position object will be held if set to Exact Grip.
- Allow Manipulation When Equipped: This parameter determines if the user should be able to manipulate the pickup while the pickup is held if using a controller.
- Orientation: This parameter determines the way the object will be held.
- Auto Hold: This parameter determines if the pickup should remain in the user’s hand after they let go of the grab button. Options include Auto Detect, Yes, and No.
- Use Text: This is the text that appears when the user has an object equipped, prompting them to “fire” the object. This requires “Auto Hold” to be set to “Yes”.
- Throw Velocity Boost Min Speed: This parameter determines how fast the object needs to move to be thrown.
- Throw Velocity Boost Scale: This parameter determines how much throwing should scale. A higher value equals a faster thrown while a lower value means slower throw speed.
- Pickupable: This parameter determines if you can pick up the pickup.
RPC’s (Remote Procedure Calls):
- Drop: If the pickup is currently held, this forces it to be dropped. Valid targets are Local and Owner.
- PlayHaptics: Plays haptic feedback on the player’s controller. Valid for all targets.
Please note that this is a technical guide and assumes familiarity with Unity and VRChat SDK. For more detailed instructions, please refer to the VRChat documentation.
TROUBLESHOOTING #
If objects are continuously spawning and falling through the world, consider the following potential causes and solutions:
- Check Colliders: Ensure that both the falling objects and the world’s ground/floor have colliders attached. If a collider is missing, add the appropriate collider component to the object or ground.
- Verify Collider Layers and Physics Settings: Ensure the colliders of the objects and the ground are set to interact with each other. Configure physics interactions by going to Edit > Project Settings > Physics, and ensure the appropriate layers are set to collide in the “Layer Collision Matrix”.
- Inspect Rigidbody Settings: Ensure that the falling objects have Rigidbody components attached. If not, add a Rigidbody component to each object. Ensure the “Is Kinematic” property is not enabled, as this can prevent objects from being affected by physics.
- Review Object Spawner Script: If you’re using a script to spawn objects, ensure that it’s functioning correctly. Double-check the object’s instantiation and any positioning or rotation adjustments. Also, ensure the script doesn’t inadvertently disable the colliders or Rigidbody components of the spawned objects.
- Check VRChat World Settings: Verify that your world’s physics settings are correctly configured in VRChat. In the VRChat SDK Control Panel, go to the Builder tab and ensure that the “Physics” checkbox is enabled in the Build & Publish settings.