Loading...

OVR Grabber & Grabbable Objects


The Oculus Grabber and Grabbable object scripts allow the Oculus Rift Touch controllers to function as hands, meaning that you can grab, throw, and interact with objects inside the VR space. This is a key aspect in most VR games and is also included in my game. I applied this technique to be able to grab the Light Cannons I had in an earlier version of my game Crater Of Light VR.


First you will need to import the “Oculus Integration” Package,

Prerequisites:

The two scripts I will be referencing are located in Oculus/VR/Scripts/Util
OVRGrabber.cs
OVRGrabbable.cs

In your scene you will also require:
OVRCameraRig (Oculus/VR/Prefabs)
Local Avatar (Oculus/Avatar/Content/Prefabs)


Oculus Touch Hands Setup
Firstly find the “RightHandAnchor” at OVRCameraRig/TrackingSpace/

  1. Add a Rigidbody.
    1. Gravity = False
    2. Is Kinematic = True
  2. Add a Sphere Collider (This is the area in which your hands can contact things).
    1. Radius = 0.1
    2. Is Trigger = True
  3. Add the OVRGrabber Script.
    1. Set Grip Transform = RightHandAnchor(your right hand)
    2. Set Size = 1
    3. Element 0 = the sphere collider on the same object.
    4. Controller = R Touch

Repeat the process for your left hand


Grabbable Objects Setup

  1. Add Rigidbody
    1. Gravity = False
    2. Is Kinematic = True
  2. Add a collider if it doesn’t already have one (Is Trigger False)
  3. Add OVRGrabber script
    1. Allow Offhand Grab = True
    2. Everything else 0 / empty / False.

Repeat this for every object you would like to grab.