How (Not) to get Started with SteamVR in Unity

Blog Posts ,Programming ,Tutorials ,Unity ,Virtual Reality ,Vive
May 11, 2016

I have a new project well under way, and today I finally had a chance to sit down and poke around with OpenVR / SteamVR to build with my Vive, which has been getting a lot of love in this household. I wanted to share a few tips that I picked up today, as well as a handy video by Sean Lee on getting the basics up and running with Vive development, which is linked down below. I have a confession to make: I messed up the first time, because I’m bad at looking at the instructions.

First things first – I tried, and I failed! This was my first foray into developing for the Vive, so I went off on a search for OpenVR, the set of APIs that Valve has made available for multi-device support across headset manufacturers. The search promptly brought me to the lovely ValveSoftware/OpenVR GitHub project, which I promptly downloaded to my machine, unzipped, and started poking through. I read over the basics of the Readme and Quick Start guide, which, frankly, wasn’t super well documented for Unity use, and decided to copy and paste two folders that seemed relevant into my open Unity project: Assets and Plugins.

As I’m being transparent here, I’d like to point out that this was a bad decision, and naturally, Unity began to get confused. I was missing an ever-important “openvr_api.dll” file. I poked around some more in the downloaded folders from GitHub, and located my very own shiny version of the openvr_api library. Success, right? One quick Ctrl+V later, I attach the SteamVR_Camera script to main camera and click play. Simple, right?

You can probably recognize that at this point that things did not go as anticipated.

The Unity editor began crying as runtime error after runtime error declared angrily that I was missing instantiated texture objects, and nothing in my scene worked. I quickly realized that my approach wasn’t going to work, so I deleted all the files I had copy-pasted into my Unity project related to SteamVR, restarted the editor, and went hunting for the proper way of doing things.

SteamVR: 1, Liv: 0

It was then that I found Sean’s video tutorial and quickly realized that I had made life significantly harder for myself by tracking down a GitHub project instead of just searching the Unity Asset Store. Had I done that, I would have found the nicely packaged SteamVR plugin for my project, and avoided all of the heartbreak of my earlier attempts. No problem, I’ve got the answer now, right?

I download the SteamVR plugin and import it into my project per Sean’s instructions. I gift myself a pat on the back for accepting all of the recommended changes that Valve suggests I make and feel the anticipation growing as I drag the SteamVR [CameraRig] prefab right into the editor, launch SteamVR, and get ready to play.

And it doesn’t work. At all. My head is awkwardly stuck in the middle of the ground. No head tracking or controllers in sight. Unity to the rescue! I left that little .dll in my Asset folder, which was causing a conflict. So I delete it. And watch it magically reappear, just seconds later.

SteamVR: 2, Liv: 0

Right around that time, I start to recognize the culprit: the file system is happily reincarnating that .dll file every time I delete it. Maybe it was git. Maybe it was just how the file system works – whatever it was, I swapped over to Explorer, deleted the extra file there, and restarted Unity one more time…

Success!

I was able to look around and see the tracked controllers and the camera adjusted properly based on my positioning. The lighthouse system worked flawlessly. The scale was definitely off, I’ve got some floor adjustments to make, and I need to optimize the hell out of the environment and the application, but I can safely say that I have my first workable scene with SteamVR for the Vive up and running. When you aren’t excessively cocky, like I was, the setup for getting the Vive integrated to Unity is incredibly straightforward. A huge kudos to the team over at Valve, I was incredibly impressed with how well the plugin worked once I had cleared out the remnants of my mistakes. I’m really excited to get working on the next stage of the app and implementing my teleportation mechanism… and, in fact, I think I hear some kittens calling…

Links

 

Sean’s video tutorial:

Basic Unity Tutorial for Steam VR & Vive (Setting up HMD and controllers) – Sean Lee

Download the Unity SteamVR Plugin: http://u3d.as/cjo

 

Related Posts

Leave a Reply