Skip to content

Grabber & Grabbable

Amon Ferri edited this page Aug 5, 2020 · 1 revision

Using the Grabber script

Attach this script to any object you wish to allow to grab other objects. In virtually every case, this will either be the LeftHandAnchor or RightHandAnchor under the OVRCameraRig's TrackingSpace.
Set the Grab Button parameter to the button the user must press to initiate a grab.
For example, if Grab Button is set to RIGHT_GRIP, and the script's parent object is currently intersecting a grabbable object, pressing the right grip will initiate a grab on the object.
For an object to be a valid grabber, it also needs a collider component (a Sphere Collider is simplest), which will be used to determine the whether or not the grabber is intersecting grabbable objects.
In the collider component, check the Is Trigger box.

Using the Grabbable script

To indicate that an object can be picked up by grabbers, attack the Grabbable script to it.
In this script, Throw Force is used to modify the force behind the object when it is released. A larger throw force creates the impression that the object is lighter, while a smaller throw force implies the object is heavier.
Velocity Average Frames is the number of frames to average the object's velocity over when determining its velocity at the point of release. This helps eliminate minor controller tracking errors and ensures the object is thrown in the proper direction. However, too large a number may result in incorrect results as well.
Any grabbable object must also have a Rigidbody component. The settings are unimportant, as long as it exists.
Grabbable objects also need a collider. According to unity documentation, this collider should have the Is Trigger box unchecked, although grabbing may still work if it is.