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
- Add Component ‘Teleportation Provider’
- Right click ‘Locomotion System’ and add an empty Game Object and call it ‘Teleportation’. Select it.
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)
- Add a ‘Teleport Interactor’ to the RightHand Controller
- Assets -> Samples -> XR Interaction Toolkit -> 2.4.1 -> Prefabs -> Interactors
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
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
- Add Component ‘Teleportation Area’
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
- Add Component ‘XR Controller’
- 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
- Starting Group Members – Select ‘Plus’ symbol twice
- 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
- Add Component ‘XR Interaction Group’
Conclusion
That should be it! With that, you’ll be able to teleport using the right thumbstick and move around with the left controller!
Do you know how the xr hands responds to locomotion? (Handsfree)