Recipe 1 - RosoVRgarden/VRgarden-tutorials GitHub Wiki

VR recipe 1: OpenXR Setup in Unity 2022.3+ (using Input Action)

  1. Launch the Unity hub and install the latest Unity 2022.3+ (LTS).

  2. To start your project, choose a name, location and a render pipeline: at the moment Universal Render Pipeline (URP) is the most efficient and the most compatible. The High Definition pipeline (HDRP) works but is more complicated in terms of setup and most plugins do not work with it.

  1. Go to the window menu > choose package manager, make sure that you are in the Unity Registry (Unity’s extensions) and type XR in the search window. You will need to install 3 things: the XR Plugin Management / OpenXR and XR Interaction Toolkit (XRI Toolkit).

You will get some warnings, about the input system, click YES and Unity will restart.

  1. In the Interaction Toolkit, make sure to import the the Starter Assets (inside Samples).

Once you install them, locate them (Assets > XR Interaction Toolkit > 2.X.X > Starter Assets). The image below uses version 2.5.1 (for version 3.0 and above, see Unity 6).

  1. Setup OpenXR, go to the Edit menu > Project Settings. OpenXR is Unity system that handles VR and AR. In the XR Plug-in Management, select OpenXR, use Single Pass (more efficient) and add controller profiles. Click + and select HTC Vive Controller and + again to add the Oculus Touch Controller for dual compatibility across the systems.

  1. Select on one of the controllers (the right controller, for example), then, in the inspector, click on the preset button (on top, next to the question mark) and click on XRI Default Right Controller.

  1. You are almost there. Go to the GameObject menu, select XR and XR Origin (VR).

  1. One more thing, select the XR Origin (XR Rig) in the hierarchy, find the Input Action Manager, click + then add the XRI Default Input Action (only one choice). You can then click on the play action on top of the Unity window and test if everything works.

  1. In order to add locomotion to your VR, select the XR Origin in the hierarchy and add the following: Locomotion System.Continuous Move Provider (Action-based), Character controller driver and Character Controller by clicking on the Add Component button.

  1. In the Continuous Move Provider (Action-based). Under Right Hand Move Action, click use reference and select XRI RightHand Locomotion/Move (Input Action Reference). Note: Alternatively, you can click +, add binding, click <No Binding>, type ‘Primary’ and select Primary2DAxis [Any]. Both solutions lead to the same result. Select Gravity Application mode ‘Immediately’ so the gravity is applied from the beginning.

  1. Finally, add a sphere under each controller (parenting) so you can see your hands. Make sure to reset their positions or your hands might feel they are in the wrong place (offset or too far).

  1. For your reference, here are the names of the button for the Vive and the Oculus.

⚠️ **GitHub.com Fallback** ⚠️