Do you have your Vive? Are you looking at SteamVR?
Are you ready to start building fun games and experiences in Unity?
Read along for some basic setup steps and a couple useful tips!
The SteamVR Plugin
This plugin has everything you need to get up and running, including some sample scenes.
If you’re looking for info on SteamVR with previous version of Unity, it’s been archived here: http://unity3d.college/steam-vr-unity-5-4-beta/
The [CameraRig] Prefab
The SteamVR team has done a great job at making it easy to start out with the Vive.
Once you’ve imported the SteamVR plugin, you can find the [CameraRig] prefab located in the SteamVR\Prefabs folder.
Create a new Scene
Delete the Default Camera
In a new scene, drag the [CameraRig] prefab into your hierarchy.
Now hit play again and enjoy the boring blue skybox.
If you don’t see anything, check your error log.
You may have a message saying:
VR: OpenVR Error! OpenVR failed initialization with error code VRInitError_IPC_ConnectFailed: "Connect to VR Server Failed (301)"!
If so, you need to launch SteamVR.
To do that, open steam and click the SteamVR icon in the top right corner.
Once it’s started, go back to Unity and click play again.
If it still fails to start, post any error message you see in the console into the comments below so I can address your problem.
An Empty World
Looking around and replacing the controllers
If all is working well now, you see the skybox and nothing else, until you turn on your controllers…
Turn them on and you should immediately notice they appear in-game. The triggers should adjust as you press them, and the trackpad should light up as you touch it (just like in the SteamVR Tutorial).
The controllers are available because of the [CameraRig] prefab. If you expand it out in the Hierarchy, you’ll see the “Controller (left)” and “Controller (right)” children.
In the image shown here, I’ve turned on only the right controller, so the left is still deactivated (dark grey).
When you’re in play mode, the “Model” child of the controller creates children for the different components.
No Controllers? – Important fix for Unity 5.6 and SteamVR
If you’re using unity 5.6 and the current version of the SteamVR plugin, you’ll notice that the controllers don’t actually turn on.
Until the SteamVR plugin is updated, you’ll need to implement this quick fix to get the controllers updating properly.
Select the Camera (eye)
Add the “SteamVR Update Poses” Component to it.
And done.. Now the controllers will track again
Replacing the Controllers
One of the questions I get quite often is “how do I replace the controllers with a [sword/gun/hand/random other thing]?”
As you may already expect, you can simply add the thing you’d like to replace the controller with as a child of the “Controller (right)” or “Controller (left)” GameObjects.
For this example, we’ll replace the controller with a shotgun (like I did in the Zombie shooter game)
First, I drag the shotgun model under the “Controller (right)” GameObject
This ‘works’, but there’s a bit of a problem. While the shotgun will move around with the controller, it won’t be aligned correctly.
Now there are a variety of ways you can fix this, but the simplest one and the one I recommend you use is to make a new GameObject for the Shotgun and have the model be a child of it.
With the “Controller (right)” GameObject selected, click GameObject->Create Empty Child
You should see this
Rename the new “GameObject” to “Shotgun”
Move the “Shotgun” model (in my case named DBS) to be a child to the “Shotgun” GameObject
Fixing alignment and position
Press play and go to your Scene view.
Because we can’t see the controller without hitting play, these changes must be done in Play mode, follow along to see how to keep those changes once you’ve left play mode.
In the Scene view, adjust your weapon model to be aligned with the controller how you want it to be (some guns for example hold at a different angle than the shotgun pictured below)
While still playing, look to the Inspector to copy the transform values
Stop playing, the gun will reset.
Now go back to the model for the gun (child of “Shotgun” in this example) and use the Paste Component Values menu option.
When you play again, your gun (or other object) should be properly aligned and move with your controller.
Once it looks right, disable the “Model” child of the “Controller (right)” GameObject.
You can delete it, but disabling it gives the same effect and allows you to easily re-enable it if you decide to make adjustments to your handheld items.
That’s all you need to get started! You should be able to look around, place objects where your hands are, and get to building stuff!
Interested in hooking into the controllers for input or other interesting Unity3d & Vive tips? Sign up now to get them delivered direct to you as soon as they’re available!
More Vive Content