Unity VR Journey

So many Controls, Not enough Hands

Separate Logic on Right Controller

Jordan T Kay
3 min readApr 20, 2024

As our project sits right now we have a full locomotion system working, the player can move with the left joystick, can snap turn with the right joystick, and can teleport with the grip buttons. But, if you have ever played a VR game before, you know the grip buttons are usually reserved for grabbing objects within the VR Space.

Looking at the controls, the right joystick is used for snap turning, and since you can not turn in the forward direction, we should create a system to enter teleportation mode when the joystick points forward (or north).

To do this, we need to use a system that separates all the necessary raycast logic, and activates the ones we need based on player input. Thankfully, the XR INTERACTION TOOLKIT comes with the necessary components to create this system.

BREAKING UP THE LOGIC

What we need to do is split up the Ray Interactor , Direct Interactor, and Transport Interactor. To do this, lets understand what each interactor does…

XR Ray Interactor → used for interacting with interactables at a distance.
XR Direct Interactor → used for directly interacting with interactables that are touching.
XR Transport Interactor → used for interacting with Transport interactables

Transport Interactor is a Ray Interactor, set on only interacting within the Teleport Layer.

Right now, all three interactors are bound to the Right Controller game Object and share the same button bindings. What we need to do is take all the logic out of the Right Controller and separate them into their own children objects.

The Ray and Direct Interactors should not have a XR Controller Script as it will be inhereted from their parent object <Right Controller>. The Teleport Interactor should obtain its own XR Controller Script, with the following adjustments from the included Presets.

Uncheck all Controller Tracking Settings (Position, Rotation, Is Tracked, and Tracking State Action)
Bind Select Action/Select Action Value to RightHand Locomotion/Teleport Select

CHANGING BETWEEN THE LOGIC

Now that we have the necessary logic separated within our Right Controller, we need something to switch between them depending on the players input.

Within the Right Controller gameobject we need the following components…

XR Controller Script → defines the basic functions of our right controller
— Ray and Direct Interactors inherit these values
Action Based Controller Manager → a script component that allows users to enable or disable controllers when the required input action is executed
XR Interaction Group → serves as a facilitator for Interactors within a system. Within this framework, a Group encompasses multiple member Interactors, organized by priority levels, ensuring that only one Interactor within the Group can actively engage in interactions (such as hovering or selection) at any given moment.

CREATE A TELEPORTATION LAYER

To ONLY have the Teleport Interactor able to interact with Teleportation Interactables, we need to…

  1. Create a Teleportation Layer
  2. Set Teleport Logic’s Interaction Layer Mask to the Teleportation Layer
  3. Set all Teleportation Interactables on the Teleport Layer
  4. Set all other logic’s Interaction Layer Mask to not work on the Teleportation Layer

Now that we have implemented the preceding logic, our raycasts shows nothing is interactable until the player holds the right joystick up (which enables the teleportation logic).

--

--

Jordan T Kay

Join my journey into game development with Unity. Learning all I can to produce quality games. 🚀