Tutorials Unity

Prevent Teleport with VRTK Policy List in Unity

Sometimes you need to prevent the viewer from teleporting into certain areas of the scene, like backstage or onto tech risers. This tutorial will outline how to use VRTK’s Policy List component to tag objects in the scene for teleport exclusion.

Assumptions: You already have a scene set up for basic teleport with VRTK and an OVR camera rig. This tutorial is using Unity 2017.4.0f1 and VRTK 3.3.0.


Add Mesh Colliders

Determine which objects in your scene you do not want the viewer to be able to teleport onto, such as the stage, chairs, people, etc. Select these objects all at the same time and add a Mesh Collider component in the Inspector window.

Perhaps you want to prevent them from walking backstage but there is no object blocking their path. In this case you could create an invisible object for the pointer to collide with in order to trigger an invalid teleport location.

Create a 3D cube object in the project panel and scale it up to take up all the 3D Space where you don’t want teleport enabled. Add a mesh or a box collider component. Then apply an albedo material with a transparent or zero value alpha channel, see screenshot below.


Set tags to ExcludeTeleport

Select all the objects in your scene that you do not want the viewer to be able to teleport through. Then, in the top of the inspector window change the tag from Untagged to ExcludeTeleport. Notice the spelling of this tag: uppercase E and T, no spacing between the words. If prompted, say yes to apply tag to all children.


Scenic Mentor 3 IconAdd VRTK_PolicyList

Select the object in your scene that has the Basic Teleport script on it. In my tutorials, I typically put this script onto an empty game object named “Play Area”. In the inspector, add the VRTK_PolicyList component onto the object.

Write “ExcludeTeleport” (Notice the caps and spacing is the same as the Tag) into the Element 0 field.


Scenic Mentor 4 IconSpecify Policy List Object

Drag the game object with the VRTK_PolicyList component onto the ‘Target List Policy’ field in the VRKT_Basic Teleport (Script) component.


Scenic Mentor 5 IconPointer Display on Invalid Location

Lastly, go into your tracked remote and confirm that your pointer renderer is showing an obvious color for invalid locations, like bright red for example. Then confirm that your VRTK_PlayAreaCursor has ‘Display on Invalid Location’ enabled.


I hope this information will make learning VR easier and more enjoyable. Subscribe to my youtube channel for more Unity and VR tutorials.

You May Also be Interested In...