Unity VR Basics 2023 – Teleportation

Besides Continuous Movement, Teleportation is the other main form of movement found in VR. Since running like in Ready Player One isn’t a reality yet, teleportation helps our player navigate a expansive environment easily. 

Teleportation Provider

Before we can use any teleportation rays, we need to add a Teleportation Provider to our Locomotion System. 

  • Expand XR Origin
    • Right click ‘Locomotion System’ and add an empty Game Object and call it ‘Teleportation’. Select it.
      • Add Component ‘Teleportation Provider’
        • System = Locomotion System
As a note, there is a setting for Delay Time. This will delay the teleportation of 

Teleportation Interactor

Now that we have a Teleportation Provider, we’ll need a Teleport Interactor in order to use the Teleportation Provider. This interactor will be responsible for casting out a ray into the environment and determine if we are able to teleport to that location or not.

  • Expand RightHand Controller
    • Assets -> Samples -> XR Interaction Toolkit -> 2.4.1 -> Prefabs -> Interactors
      • Add a ‘Teleport Interactor’ to the RightHand Controller
        • Interaction Layer Mask = Teleport (If there is no Teleport Interaction Layer, Add it to the 31 slot)

For some reason, Unity suggests that we make sure to have a Teleport interaction layer on the 31 slots for interaction layer masks. I’m not entirely sure why they suggest this or why they don’t automatically add this to the Layers when installing the XR Interaction Toolkit, but Unity has been doing a lot of things lately that do not make sense…

Teleportation Area and Anchor

In order to use the Teleportation Interactor, we need to have an area to teleport to. To do this, there are two ways to denote a teleportable area.

  • Teleportation Anchor – This is a specific location that our users can teleport to. It can also be set to have a specific orientation for the user once they teleport to it.
  • Teleportation Area – This is an entire plane that the user can teleport to. 

To start off, let’s make a Teleportation Anchor.

  •  Assets -> Samples -> XR Interaction Toolkit -> 2.4.1 -> Prefabs -> Teleport
    • Add a Teleport Anchor to the Scene
From here, we can customize our Teleport Anchor by using a different Material. We can also determine the orientation of our player when they teleport using the  Match Orientation and setting it to ‘Target Up and Forward’. The forward facing direction is based on the Z of the anchor and the up is determined by the Y.
 
This type of teleportation is great for when you want to have more control over how your user experiences your game. Maybe you want them to focus on a specific table or lever on a wall, but don’t wish for them to explore outside of that area.

Next, let’s turn our plane into a Teleportation Area.

  • Select the Plane in the Scene
      •  Add Component ‘Teleportation Area’
        • Interaction Layer Mask = Teleport
        • Match Directional Input = True
With just that, we should now be  able to teleport our Scene. We will also be able to rotate our reticle for teleportation thanks to the Match Directional Input to True. The only problem now, is that we must use our grip button to teleport. We also cannot rotate our orientation with our thumbstick before we teleport, so lets fix that!

Improving Teleportation Controls

To fix our controls, we need to update our Teleport Interactor. 

  •  Select the Right Teleport Interactor
    • Add Component ‘XR Controller’
      •  Set the XR Controller to be based on XRI Right Hand Controls
      • Position Action = False
      • Rotation Action = False
      • Is Tracked Action = False
      • Tracking State Action = False
      • Select Action -> Reference = XRI RightHand Locomotion/Teleport Select
      • Select Action Value -> Reference = XRI RightHand Locomotion/Teleport Select
      • Model Prefab = None
 
      •  
  • Select Right Controller
    • Add Component ‘XR Interaction Group’
      • Starting Group Members – Select ‘Plus’ symbol twice
        • First Slot = Teleport Interactor
        • Second Slot = Direct Interactor
    • Add Component ‘Action Based Controller Manager’
      •  Manipulation Interaction Group = RightHand Controller Interaction Group
      • Direct Interactor = Direct Interactor (RightHand)
      • Ray Interactor = Ray Interactor (RightHand)
      • Teleport Interactor = Teleport Interactor (RightHand)
      • Teleport Mode Activate = XRI RightHand Locomotion/Teleport Mode Activate
      • Teleport Mode Cancel = XRI RightHand Locomotion/ Teleport Mode Cancel
      • Turn= XRI RightHand Locomotion/ Turn
      • Snap Turn = XRI RightHand Locomotion/ Snap Turn
      • Move = XRI RightHand Locomotion/ Move
      • UI Scroll = XRI RightHand Interaction/ UI Scroll

Conclusion

That should be it! With that, you’ll be able to teleport using the right thumbstick and move around with the left controller!

1 thought on “Unity VR Basics 2023 – Teleportation”

Comments are closed.