Steam VR Updates: How to Setup Teleport Mechanics
A couple of weeks ago, SteamVR released an update that changed things pretty drastically. It’s been a while since I’d used the plugin (almost a year or so), so I was really surprised when I pulled it into my latest project and noticed that the scripts I was used to seeing no longer existed… I was very confused. Essentially, the plugin no longer requires us to code to specific buttons… I suppose it’s still possible (a topic for another post), but the plugin makes it so easy to get things setup to use teleportation movement.
- Create a Unity project and import the SteamVR plugin from the asset store.
- After it’s imported, go to Window > SteamVR Input. This is where SteamVR sets up any “actions” (i.e. button presses, inputs, etc.). Click “Save and Generate”. SteamVR will create a new folder in your Assets called SteamVR_Input.
- After you’ve done this, in your scene, search for and drag in the “Player” prefab. Or you can navigate through your folders. Assets > SteamVR > InteractionSystem > Core >Prefabs. This is essentially the camera rig. It contains the cameras and controllers.
- Next, you’ll drag in the “Teleporting” prefab. (Assets > SteamVR > InteractionSystem > Teleport > Prefabs) The Teleporting prefab is what handles the raycasting, coloring of the line renderer, teleporting audio, etc.
From here you’ve essentially got two choices. To have teleport points or teleport areas.
Individual points is a common option if you want to restrict where people can teleport in your scene. SteamVR makes this so simple now. As long as you have the Teleporting prefab in the scene, drag in some of the “Teleport Points” prefabs. (Assets > SteamVR > InteractionSystem > Teleport > Prefabs)
You can decide whether you want the point to be locked or not. The Teleport Point component has some features that aren’t on the Teleport Area. One nice feature is that you can have a “Teleport Type” of switch scene which which will enable you to go to another scene when teleporting there.
When you play the scene, you’ll press down on the touch pad or in on the thumb stick to create the pointer, point toward a teleport point and release to teleport.
If you want to have larger teleportation areas instead of individual points, here’s how that would work.
- Now we need an area to teleport around on. Let’s create a plane and then a second plane as a child of the first. We’ll reset the transform on the first plane, and raise the second (child) plane just a tiny bit to prevent collisions. I usually set my second one at 0, 0.05, 0.
- Next, add a “Teleport Area” component to the child plane. The teleport area needs and replaces a mesh renderer. Whatever object you want your teleport area to be, it needs to have a mesh renderer on it, so it can’t be an empty game object.
Your second plane should look something like this:
When all this is done, your hierarchy should look like this:
When you run it, you’ll press down on the touch pad or in on the thumb stick to create the pointer, point toward a spot on the plane and release to teleport.
Another note… If you’re using SteamVR with an Oculus headset, like I am, you may find that in order to get the headset and controllers working correctly you may need to go into your Player Settings and remove Oculus from the list of Virtual Reality SDKs. Initially, I wasn’t seeing my controllers when I had Oculus in the list. I tried reordering them to put OpenVR above Oculus, but that didn’t seem to fix the issue. In order to get the controllers to show up, I had to remove Oculus from the list completely.
Check out my next post in this series on Interactions with the new SteamVR plugin updates.