Lab8: Into VR



The goal is to try out creating an interactive environment for VR headsets and hand controllers. You will be using the VRToolkit, which provides a number of useful building blocks and tons of documentation.


Because there are only three computers hooked up to VR devices at CADIA, you will need to follow the procedure on your own machine and testing it first using a simulator rig (comes with the VRToolkit, explained below) and then when you are relatively certain things are working, copy a build of the application to a shared network drive (e.g. \\\cadia\Courses\VIEN2017) and then run it on an available VR computer. Therefore you should start by making sure you can access this network drive (get help if you are stuck).

Tutorial Videos

The procedure below is more or less covered in these two official VRTK tutorial videos (you do not have to watch them first, you can simply refer to them as needed)

Working with Multiple SDKs
Pointers, Teleporting and Object Interactions


  1. Getting Started You have to start by importing the following packages: OculusUtilities, OvrAvatar, VRToolkit (from Asset store or from the VRToolkit Github Repository), SteamVR (from Asset store) and Prototyping. You will probably need to delete the Samples folder from OvrAvatar to get rid of some compilation errors.
  2. Create Basic Environment Add a floor with a material that is easy on the eyes. Put a small cube on it (1m tall), as a table, and a small sphere on top of the cube (20 cm diameter). Make the floor and table static and put under a new empty object called Environment. Put the sphere under a new empty object called Props. Add a comfortable ambient sound to the environment to make you feel you entering a different world.
  3. Create Empty VRTK Object Hierarchy Create 9 Empty Game Objects in the Hierarchy. Arrange and rename them exactly as shown by the lower 9 black and gray objects in the screen shot above (VRTK_SDKManager, SDKSetups, SteamVR, OVR, Simulator, VRTK_Scripts, LeftController, RightController, PlayArea). Make sure the position of all these objects is (0,0,0). Note that they are all still empty!
  4. Set Up VR SDK Switching
    1. Add the VRTK_SDK Manager component to the VRTK_SDKManager object. Add the VRTK_SDK Setup component to each of the SteamVR, OVR and Simulator objects.
    2. Do the following to set up the VR Simulator option:
      1. From the VRTK->Prefabs->CameraRig->SimulatedCameraRig project folder drag VRSimulatorCameraRig under the Simulator game object (as child).
      2. In the VRTK_SDK Setup component of the Simulator game object, select Simulator from the QuickSelect drop down.
    3. Do the following to set up the SteamVR (HTC Vive) option:
      1. From the SteamVR->Prefabs project folder, drag [CameraRig] and [SteamVR] under the SteamVR game object (as children).
      2. In the VRTK_SDK Setup component of the SteamVR game object, select SteamVR from the QuickSelect drop down.
    4. Do the following to set up the Oculus option:
      1. From the OVR->Prefabs project folder drag OVRCameraRig under the OVR game object (as child),
      2. From the OvrAvatar->Content->Prefabs project folder drag LocalAvatar under the same OVR game object
      3. Select the OVRCameraRig and in the inspector choose Floor Level as the value for Tracking Origin Type
      4. Select the LocalAvatar and in the inspector check the Start With Control option (to see the controllers in the world).
      5. In the VRTK_SDK Setup component of the OVR game object, select Oculus from the QuickSelect drop down.
    5. In the VRTK_SDK Manager component of the VRTK_SDKManager game object, press Auto Populate to see all of the VR setups listed. The list is in the launch order. If something fails to launch, the next setup will be tried. Therefore, you should drag the Simulator setup to the bottom of the list, so it becomes the fallback if no VR equipment is connected.
    6. Check the SDK_OCULUS_AVATAR check box in the same VRTK_SDK Manager component.
    7. From the VRTK->Prefabs project folder drag the SDKSetupSwitcher under the VRTK_SDKManager as a child.
  5. TEST You should be able to see your scene in any of the VR setups, including the Simulator. You may want to adjust the position of your camera rigs so that you start standing in front of the table.
  6. Making Props Grabbable Add the following components to a prop you want to grab:
    1. Rigidbody
    2. VRTK_Interactable Object (check Is Grabbable)
    3. VRTK_Child Of Controller Grab Attach (drag this component also into the Grab Attach Mechanic Script field of VRTK_Interactable Object)
    4. VRTK_Outline Object Copy Highlighter
    5. VRTK_Interact Haptics (Set Strength On Touch to 1 and Duration On Touch to 0.2)
  7. Activating Controllers Add the VRTK_Controller Events and VRTK_Interact Touch and VRTK_Interact Grab components to both the LeftController and RightController game objects. Select the VRTK_SDKManager game object and drag the LeftController object into the Left Controller field of the VRTK_SDK Manager component and the RightController object into the Right Controller field.
  8. TEST You should be able to pick up your props.
  9. Adding Teleportation Do the following:
    1. To the RightController game object, add the VRTK_Pointer component,
    2. the same RightController game object, add the VRTK_Bezier Pointer Renderer component.
    3. Drag the VRTK_Bezier Pointer Renderer component into the Pointer Renderer field of the VRTK_Pointer component.
    4. To the PlayArea game object, add the VRTK_Basic Teleport component.
    5. Move your camera rig(s) a bit further back from the table, so you can try teleporting towards it.
  10. TEST You should be able to click the touch pad / joystick to make a telaportation arc appear, which takes you to its destination when releasing the pad / joystick.
  11. Go Wild! Add more props. Try different Grab Attach Mechanics. Try different object highlighters. Fiddle with appearance.

Updated by Hannes Vilhjálmsson over 3 years ago · 9 revisions