VR in Unity: Creating a Teleportation System!

Chase Mitchell
4 min readMay 14, 2021

One of the biggest limitations of VR gameplay is the play arena. Players are locked within a confined bounds defined as their safe play area, so how do you create systems for players to explore? Teleportation is a widely used and effective solution.

This post is a continuation of my other VR guides and we’ll use the same VR Rig set up for those guides here.

Fortunately many of the tools for creating a teleportation system are built in. The first step is to add two new components to our VR Rig — the Locomotion System and Teleportation Provider. The required fields for these components will automatically assign to our VR Rig on Play.

Next right click in the Hierarchy and create an XR -> Device Based -> Ray Interactor object. Child this under CameraOffset and reset the position values to 0. We can rename it to Right Teleport Ray. Inside the XR Controller component, update the Controller Node to Right Hand. Running the game will now show a ray being produced from out right hand.

This interactor ray can interact with several types of objects — for example it can grab distant objects or interact with UI menu items. In our case it will be used to set the destination for our teleport.

Notice the Ray turns white when it intersects an interactable object.

There are two methods to set up our teleport functionality — the Teleport Area and the Teleport Anchor.

Teleportation Area

To create a teleportation area right click in the Hierarchy and select XR -> Teleportation Area. This will create a new plane in your scene which can be used to teleport anywhere onto. You can also simply apply Teleportation Area as a component to any object with a collider, such as a cube. If the object the TP Area is added to has a collider on it it will be recognized automatically, otherwise (if for example the collider is on a child object) you can drag in the appropriate collider to the TP Area component.

Teleportation Anchor

The Teleportation Anchor appears similar to the TP Area, but with a few differences. Create a new TP Anchor by right clicking in the hierarchy and selecting XR -> Teleportation Anchor. The TP Anchor includes an additional child component called the Anchor. When you teleport onto this area, the player will be placed at the exact position of the Anchor. You can modify the Match Orientation setting to determine whether the rotation will be set from World Space Up or the Target Up.

You can imagine use cases for the Anchor in which you want the player to be able to select a wide area as their next destination, but you want them to arrive at a fixed point with a fixed orientation when they arrive at that destination.

Teleportation Settings

With a few object set up in our scene with teleportation areas and anchors we can test this out. As you can see this is a very efficient method for navigating your scene!

Currently our Ray Interactor Usage button is set to Grip, but this can easily be changed by modifying the “Select Usage” value from Grip to Trigger on the XR Controller component of the Ray Interactor.

You can also control which objects can be interacted with by creating layers and adding objects you intend to be non-interactable (such as the ball) to a new layer. In the XR Ray Interactor component you can update the Interaction Layer Mask settings to exclude these certain layers from being interactable with your ray.

Another setting to be mindful of in this component is the Selection Action Trigger — if you update this field from State to allow State Change, you can depress the trigger on a non-interactable object but release it on a teleportation area and you will still be able to teleport.

That’s it for the setup of a basic teleportation system, in the next guide I’ll cover how to implement some of the advanced aesthetics to make your teleport function look a little more professional. See ya there!

--

--