Tutorial: Creating Virtual Reality Applications
The Makerspace currently has two types of virtual reality systems including the Oculus Rift DK2 and the HTC Vive. This tutorial will guide users through the process of creating and testing a VR application in Unity3D.
Phase 1: Basic VR Project
The first type of application we will be creating shall allow the player to interact with an immersive environment by teleporting and picking up throwable objects. To begin, launch the Unity engine and create a new project.
- Create a new Plane GameObject by right clicking in the hierarchy view and selecting 3D Object>Plane. A flat plane should appear in your scene view.
- Navigate to the Asset Store by either pressing Ctrl+9 or navigating to Window>Asset Store.
- In the search bar, type "SteamVR" and press enter. Locate and install the SteamVR Plugin by Valve Corporation.
- Switch back to the scene view and open the SteamVR folder in your Assets panel (project panel).
- Using the asset search bar, locate the "Player" prefab, and drag it into your scene view, placing it atop the Plane object we created earlier.
- Search for the "Teleporting" prefab in the asset folder and drag it into your hierarchy, the position is not important.
- Search for the "Teleport Point" prefab in the asset folder and drag them into your scene view as many times as you deem necessary. Each point can be teleported to by the player and will allow them to navigate your scene.
Your VR game should now have teleportation as an ability. You can play test this by running the game and pressing down on the Trackpad. Next, we will add interactable objects to our scene.
- Create a new game object and place it near the player above the Plane. Any 3D object is fine as long as it has a collider.
- Search in the assets folder for a script called "Throwable" and apply it to the game object we just created via dragging it into the Inspector, or directly onto the object in the scene view.
Now the object should be interactable. When testing the game, move your controller near the game object and pull and hold the trigger. This will allow you to pickup the object.