Recipe 1 Unity6 - RosoVRgarden/VRgarden-tutorials GitHub Wiki

VR recipe 1: OpenXR Setup in Unity 6.0.

  1. Launch the Unity hub and install the latest Unity 6000.0.0+ (LTS).
  1. To start your project, choose a name, location and a render pipeline: at the moment Universal 3D (Universal Render Pipeline or URP) is the most efficient and the most compatible. The High Definition 3D (High Definition Render Pipeline or HDRP) works but is more complicated in terms of setup and is less compatible with assets.
  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. Once you install them, locate them in your project (Assets > XR Interaction Toolkit > 3.X.X > Starter Assets). The image below uses version 3.0.7.
  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. Have a look at the Hierarchy. The XR Origin is the main component of virtual reality. It is composed of the Camera Offset, the Locomotion and the XR Interaction Manager. The Capsule is an extra element that I use to trigger interaction with the ground.
  1. You can create this on your own by going to the GameObject > XR and select XR Origin (VR).
  1. The XR Origin has information about the height of the user (Tracking Origin Mode but can also be changed in the Camera Y Offset). It's also where you add a Character Controller so you can interact with the ground and walls (change the Radius to make yourself thinner, for example).
  1. XR Origin also holds the Input Action Manager, click + then add the XRI Default Input Action. 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, create an empty object named Locomotion and add it into your XR Origin. You need to add two components: Locomotion Mediator and the XR Body Transformer. Make sure that the XR Body uses the Character Controller.
  1. In Locomotion, create a new game object called Move and add a Dynamic Move Provider. You can change the speed of your character (Move Speed) and change the input to XRI Left Locomotion/Move (Input Action) which means that the movement will be directed by the joystick on your controller (Oculus or HTC). If you have some hands, you can put them in the Left/Right Controller Transform.