Unity SteamVR Basics Part 1: Setting up

This tutorial will be the first of a new series on getting started with SteamVR development in Unity. In this tutorial we will setup a very basic scene with a VR camera and VR controllers.

This tutorial assumes that you’ve already installed Unity. If you haven’t, you can download and install the latest version from the Unity website.  For this tutorial I will be using the latest Unity version: 2017.4.

The tutorial also assumes that you are familiar with the basics of Unity. In the following tutorials of this series we will also be creating our own scripts, so you also need to be familiar with C#.

Setting up the project

Start Unity and create a new 3D project. I’ve called my project SteamVRTutorial1, but feel free to make your own name for the project.

We will need to add the SteamVR plugin to our project. Open the Unity Asset Store by clicking the Window -> Unity Asset Store button or use the keyboard shortcut Ctrl+9 to open the Unity Asset Store. The name of the plugin is “SteamVR Plugin”. Find the plugin and click the Download or Import button. Import all the assets of the plugin into your project.

The SteamVR plugin contains alot of prefabs and scripts we can use to get our project up and running in no time.

Installing SteamVR
Installing SteamVR from the Unity Asset Store

Creating our scene

Let’s create a basic scene containing a Plane that will be our ground floor. Open the top-menu “GameObject” menu and click on 3D object -> Plane.  Make sure to save the Scene so you won’t lose any progress.

Because we are creating a VR game, we need to delete the Main Camera object. You don’t need a Main Camera for a VR game, since the headset will be the camera. The SteamVR plugin contains several useful prefabs we can use for our scene. One of the prefabs we are interested in is the Player prefab. The Player prefab will contain the a camera for the VR headset and a pair of hands we can use to interact with items in our scene.

You can find the Player prefab at the following location:
Assets -> SteamVR -> InteractionSystem -> Core -> Prefab -> Player

Go ahead and add the prefab to our scene. Make sure to reset the Player gameobject position, so the x, y and z positions are all set to 0.

Starting our “Game”

Let’s go ahead and start our scene. You can use your headset to look around the scene and you should be able to see your HTC Vive or Oculus Rift controllers in-game. It’s not much of a game right now, but we have the basic systems in place to work with in the next tutorials.

Rendering the scene
Look mom, I’m in virtual reality

Tip: Switching between VR mode and 2D mode

One of the cool features of the SteamVR plugin is that you can switch between VR and 2D debugging mode. When you’ve started your game, you can use the “2D Debug” button in the Game view to switch between the two different modes. The advantage of using the 2D debug mode is that it allows you to easily debug your game without having to put on your VR headset all the time.

2D debugging mode

In 2D mode, you can move around using the WASD/arrow keys on your keyboard and you can the right mouse button to rotate the camera.

Moving forward

This was a very basic setup tutorial in which I’ve explained how to add the SteamVR plugin to a new Unity project. The SteamVR plugin makes it super-easy to add VR functionality to new or existing games. Using the 2D mode of the SteamVR plugin, we can easily debug our games without having to put on our VR headset all the time.

In the next tutorial we will be taking a look at how we can move around in our scene using the teleportation mechanism.

Leave a Reply

Your email address will not be published.