Teleportation is one of the most used movement systems in VR games. You point where you want to go and, boom, you’re there. The SteamVR plugin for Unity has some built-in teleportation features that we can use to get it up and running in no time.
In this tutorial we will take a look at the built-in teleportation mechanisms and how we can use them in our game.
Why use teleportation?
In most games the game world is probably larger then the physical room of the player. Teleportation is one of the best ways to allow the player to move around in the game world without being limited by the physical space of the players room.
Other movement systems such as locomotion can cause serious motion sickness or instability – especially for inexperienced VR users. Teleportation is one of the most user friendly ways of navigating the virtual world.
SteamVR teleportation components
The SteamVR plugin contains several prefabs and script we can use to enable teleportation in our games. You can find these prefabs and scripts in the Assets -> InteractionSystem -> Teleport folder.
The prefabs and script we will be using in this tutorial are:
Prefabs -> Teleporting: This prefab enables the teleportation system. It handles all player input regarding teleportation, highlights teleportation markers and it allows the player to teleport to the designated teleportation area’s.
Prefabs -> TeleportPoint: A teleportation point is a small point to which the player can teleport.
Scripts -> TeleportArea: You can add the teleport area script to a 3D object, so the player can teleport to this area.
In this tutorial we will add teleportation to the Unity project that we built in part one of this tutorial series.
The first thing we need to do to add teleportation to our scene is to add the Assets -> InteractionSystem -> Teleport -> Prefabs -> Teleporting prefab to our scene. Add the prefab and reset it’s position so the x, y and z coördinates are set to 0.
Now we can start adding some teleportation points to our scene so the player can teleport around the room. Add four TeleportPoint (Assets -> InteractionSystem -> Teleport -> Prefabs -> Teleporting) prefabs to the scene on various locations.
That’s it! By adding the Teleporting and TeleportPoint prefabs to our scene we’ve done everything we need to do to enable teleportation in our scene. Let’s start the game to inspect the results.
You can use the trackpad to teleport to the different teleportation points. If you’re using the 2D debug mode to test your game, you can use the “T” key to teleport instead.
Teleportation points can be usefull, but for most games you will probably want to use teleportation area’s. Unfortunatly, the SteamVR plugin does not contain a teleportation area prefab. It’s easy to create our own prefab though, and that’s exactly what we are going to do now.
First things first, let’s delete all the teleportation points we added to our scene. Since we are going to use a teleportation area, we won’t need the teleportation points anymore.
We are going to add a new Plane to our scene. This Plane will representour teleportation area. Click GameObject -> 3D object -> Plane to add a new Plane to our scene. Reset the position of the Plane so the x, y and z coördinates are set to 0. Let’s name the Plane “TeleportationArea”.
The next step is to add the Assets -> InteractionSystem -> Teleport -> Scripts-> TeleportArea script to the Plane we just added.
When you try to run our game, you’ll notice you aren’t enable to teleport anywhere. This is because our TeleportationArea Plane is overlapping with our ground Plane. We can easily resolve this by setting the Teleportation Plane Y coördinate to 0.01.
That’s the basics of adding teleportation to our game using the SteamVR plugin for Unity. If you have any questions or feedback, feel free to let me know in the comment section.