VR Interaction – SteamVR Lab Interaction System – Throwables
Today, I’ll introduce you to VR Interaction using the Lab Interaction System. If you’ve played The Lab, you already know it includes a variety of different interactions spread across a flurry of mini-games. With a 98% positive review rating, it’s one of the most popular VR experiences, and the interaction system is one of my favorite parts.
Getting started with The Lab Interaction System only takes a couple quick steps. In this guide, I’ll show you the setup and how to create your first grabbable & throwable object.
Setup The Lab Interaction System
Create an empty project
Import the SteamVR asset from the Asset Store
In your empty scene, delete the “Main Camera”
Add the [CameraRig] prefab from the SteamVR/Prefabs folder into your scene.
Create a new empty gameobject and name it Player
Reset the position of the Player in the Inspector
Right click on the “Player” GameObject in the hierarchy and create 2 Empty Children
Hands Setup
Name them LeftHand & RightHand
Add the Hand component to both the LeftHand & RightHand
Select the LeftHand
In the Inspector, drag the RightHand to the “Other Hand” field.
Select the Right Hand
Assign the “Left Hand” to the “Other Hand” field
Change the “Starting Hand Type” to Right
Controller Prefab
Because we’re not assigning any actual hand models here, we’ll want to fill in the Controller Prefab field. This will allow the hands to automatically create controller models much the same way the default [CameraRig] controllers do.
Select the left hand and assign the “BlankController” prefab to the “Controller Prefab” field.
Repeat this for the RIGHT HAND
The BlankController prefab can be found in the SteamVR/InteractionSystem/Core/Prefabs folder
Player Setup
Select the “Player” in the Hierarchy.
Add the Player Component to the “Player” GameObject
Drag the hands onto the “Hands” array.
Expand the [CameraRig] and select the “Camera (eye)”
Right click on the Camera (eye) and add a new 3d Object->Sphere as a child.
In the Inspector, change the Sphere Scale to 0.1, 0.1, 0.1
Uncheck (or remove) the Mesh Renderer component of the Sphere
Select the Player
Assign the newly created Sphere to the “Head Collider” field of the Player component
Drag the [CameraRig] to the “Rig Steam VR” field
Environment Setup
So far, we have the player all setup with hands and ready to go. It’s time to create a little environment where we can grab and throw things!
Create an empty Plane
Reset the position
Create a Cube
Set the transform values to match the image above – position = (0, 0, 2.5) | scale = (1, 1, 4)
Your scene view should look similar to the image here.
Throwables
Ok it’s time to make something throwable, luckily this is the easiest part.
Create a new empty Sphere
Rename it “Ball”
Set the Scale to (0.1, 0.1, 0.1)
Set the Position to (0, 0.6, 0.7)
Your ball should now be just above the Cube like this
Add the “Throwable” component to the “Ball”
You’ll immediately see a few other components get added to the ball automatically.
That’s it..
Press Play
Pickup your ball (with the Trigger) and throw it!
Conclusions
The SteamVR Lab Interaction system is actually very featured and this only covers the first of many possible interactions available. The player and hand setup you have here will work as a great starting point for exploring the other interactions. For a full demo of all the interactions, make sure you check out the “Interactions_Example” scene in the SteamVR/InteractionSystem/Samples/Scenes folder. Also if there’s a specific interaction type you’d like more info on, please comment below and let me know.