Lab8: Into VR¶
NOTE: THIS IS OUTDATED, UNITY HAS STARTED OFFERING A NEW SYSTEM THAT COMPETES WITH VRTK AND IS CALLED XR Interaction Toolkit, use that instead!
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. \\dfs.ru.is\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).
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)
- 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.
- 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.
- 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!
- Set Up VR SDK Switching
- 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.
- Do the following to set up the VR Simulator option:
- From the VRTK->Prefabs->CameraRig->SimulatedCameraRig project folder drag VRSimulatorCameraRig under the Simulator game object (as child).
- In the VRTK_SDK Setup component of the Simulator game object, select Simulator from the QuickSelect drop down.
- Do the following to set up the SteamVR (HTC Vive) option:
- From the SteamVR->Prefabs project folder, drag [CameraRig] and [SteamVR] under the SteamVR game object (as children).
- In the VRTK_SDK Setup component of the SteamVR game object, select SteamVR from the QuickSelect drop down.
- Do the following to set up the Oculus option:
- From the OVR->Prefabs project folder drag OVRCameraRig under the OVR game object (as child),
- From the OvrAvatar->Content->Prefabs project folder drag LocalAvatar under the same OVR game object
- Select the OVRCameraRig and in the inspector choose Floor Level as the value for Tracking Origin Type
- Select the LocalAvatar and in the inspector check the Start With Control option (to see the controllers in the world).
- In the VRTK_SDK Setup component of the OVR game object, select Oculus from the QuickSelect drop down.
- 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.
- Check the SDK_OCULUS_AVATAR check box in the same VRTK_SDK Manager component.
- From the VRTK->Prefabs project folder drag the SDKSetupSwitcher under the VRTK_SDKManager as a child.
- 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.
- Making Props Grabbable Add the following components to a prop you want to grab:
- VRTK_Interactable Object (check Is Grabbable)
- VRTK_Child Of Controller Grab Attach (drag this component also into the Grab Attach Mechanic Script field of VRTK_Interactable Object)
- VRTK_Outline Object Copy Highlighter
- VRTK_Interact Haptics (Set Strength On Touch to 1 and Duration On Touch to 0.2)
- 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.
- TEST You should be able to pick up your props.
- Adding Teleportation Do the following:
- To the RightController game object, add the VRTK_Pointer component,
- the same RightController game object, add the VRTK_Bezier Pointer Renderer component.
- Drag the VRTK_Bezier Pointer Renderer component into the Pointer Renderer field of the VRTK_Pointer component.
- To the PlayArea game object, add the VRTK_Basic Teleport component.
- Move your camera rig(s) a bit further back from the table, so you can try teleporting towards it.
- 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.
- Go Wild! Add more props. Try different Grab Attach Mechanics. Try different object highlighters. Fiddle with appearance.