Easy Unity VR Tutorial for Beginners

XR Bootcamp
February 17, 2022

Unity VR Tutorial

Are you new to VR ? Are you wondering how to create a VR App? How to create a VR Game? Welcome to this Unity VR Development Tutorial (Oculus Quest 2 Tutorial - Oculus Quest Tutorial).

After reading this guideline, you can create your first VR scene in Unity! 

How to’s answered in this article

  • How To Install Unity for VR
  • How to add XR camera and hand controllers
  • How to Move around a VR scene
  • How to Interact with VR game objects (grab)

Skills Required: None. Beginner level.

Hardware Required: PC or laptop with Windows, Linux or Mac OS (Windows recommended). Oculus Quest 2 with headset and hand controllers

In this blog we will create a VR demo scene in which the player will be able to move (teleport) and interact with game objects in a VR environment.

If you already have Unity installed and know how to create a new 3D project, you can jump to add modules or XR settings

Installing Unity and modules

Installing Unity Hub

Unity VR Tutorial. Unity Hub is an application used for handling different  Unity editor settings, such as editor version, creating a new project or opening an existing one, etc.

For installing Unity Hub click on the Download Unity Hub button here: Download - Unity (unity3d.com) (see image below).

The page also displays the computer requirements. A PC or laptop with Windows OS is the recommended option.

Unity Hub is a standalone application that streamlines the way you find, download, and manage your Unity Projects and installations. More info here

Easy Unity VR Tutorial for Beginners

After the file has been downloaded, double click on it to install. A new window will appear. 

  • You should read the text and click on “I agree” to continue
Easy Unity VR Tutorial for Beginners
  • Select the installation folder
Easy Unity VR Tutorial for Beginners
  • Click on Finish to start Unity Hub
Unity VR Tutorial

A new window like this should appear. 

Let me introduce you to Unity Hub!

Installing Unity

Unity VR Tutorial: In Unity Hub, click on Installs (left) and later on Install editor (blue button, right)

For this tutorial we’ll use the 2021.2.8f1 version, so we’ll need to click on the Archive tab and click on download archive link (blue text, see image below). It will redirect you to the Unity archive webpage, in which you will find the editor versions that can be installed.

Click on the Unity Hub button of Unity version 2021.2.8

Adding Unity modules and Script editor

An Oculus app is created (built) with Android OS, so we will need to install some additional modules in Unity.

After clicking on the button described above, a new window should appear (see image below). Select the following options:

  • Microsoft Visual Studio Community 2019
  • Android Build Support
  • Android SDK & NDK Tools
  • OpenJDK
  • Windows Build Support (IL2CPP)

Although in this tutorial we won’t create scripts, it is recommended to install Visual Studio.

Visual Studio is a C# editor, the script programming environment used in Unity.  The Community version is free. More info here

Creating a new project

Do you remember the main window in Unity Hub?

This is used for several purposes. One of them is creating new projects.

  • To create a new project, click on the blue button at the top right

In the next window:

  • Check if the Unity editor version is correct (2021.2.8f1)
  • Select 3D. This will be our project’s template.

Why not the VR template? because it doesn’t include the XR Interaction Toolkit (this is a Unity software package) that will be used in this tutorial.

  • Choose a Project name and its Location
  • Click on the Create project button

3D will be our project’s template.

After some time, the Unity editor will be loaded, and a new window will appear for you to give it a try clicking on the different options available to familiarize with the editor.

XR Settings configuration

What is XR?

XR is a term used to include several types of applications such as VR (Virtual Reality), MR(Mixed Reality) and AR(Augmented Reality). More info here

To configure our Unity project for XR, we will need to use a software package called XR Plugin Management. It manages and helps the user with loading, initialization, settings, and build support for XR.

XR Plugin Management

  • Go to Edit/Project Settings
  • Click on XR Plugin Management (bottom left)
  • Click on Install XR Plugin Management
  • Now the XR Plugin Management option will look like this:

  • In the Unity manual, the description of this package is: “provides simple management of XR plug-ins. Manages and offers help with loading, initialization, settings, and build support for XR plug-ins.

    • Among the options above, check OpenXR with PC tab selected

What is OpenXR?

  • It’s a standardized interface that allows you to configure several XR inputs (i.e. Oculus Quest 2, for the Oculus Quest 2 Tutorial) in a single project and translate them into multiple headsets and platforms. More info here

    A new window may appear asking you to enable Unity's Input System.

  • If you’re working on a new fresh project, Click on Yes. Otherwise, if you are using the old Input Manager, you should consider both options

After the step above, a warning message may appear:

  • Click on the yellow icon. It will show a new window
  • Click on Edit
  • Select the Oculus touch controller profile as shown below from the new window
  • Interaction profile: type of configuration required for the headset you’ll be interacting with.

    In the same window, be sure that Render Mode is set to Multi pass
  • Multi-Pass renders the Scene into two images shown separately for each eye, and is the recommended option.

    Single-Pass combines both images into a single double-width Texture, where only the relevant half is displayed to each eye.

    Go to the Android tab and select Oculus
  • Select Oculus option below XR Plugin Management. It should look like this:

Configuring VR inputs as actions

  • Inputs are actions taken from the Player through a device (for example mobile, PC or VR headset like the Oculus Quest or Meta Quest for the Oculus Quest 2 Tutorial, Meta Quest Tutorial) that will be identified by the game engine editor (Unity) and will “trigger” or execute some other actions in the program, application or game. 

    One example is firing. When the player presses (input action) the “Fire” button on a mobile game, it starts to spawn bullets (action triggered in the game) in a certain direction.

    Now we will configure the XR Interaction toolkit, a framework that works pretty well with OpenXR.

Installing XR Interaction Toolkit

  • Go to Window/Package Manager
  • Click on the + button
  • Select “Add package from git URL”
  • Write “com.unity.xr.interaction.toolkit” and click on Add
  • It will show a warning window informing you that if you have an older XR Interaction Toolkit version you should make a backup before updating to this newer one. 

  • Click on “I Made a Backup” if you have a new fresh project or, well, if you made a backup
  • After installed, select the package and import the Default Input Actions

These Default Input Actions are pre-configured actions that are already set up and ready to go.

The XR Interaction Toolkit will identify the inputs in the Unity’s VR project and will use OpenXR that will be in charge of translating them into the desired VR platform (in this case, Oculus)

Your assets folder in the project tab should look similar to this:

If you go into the XR Interaction Toolkit folder, you should have these sample XR interaction files (except by the file with the blue ray):

Select each file and Add it to the project by clicking on “Add to …” in the inspector tab

Go to Edit/Project Settings/Preset Manager and write “Right” and “Left” for the corresponding Action Controllers (see image below, bottom middle)

Scene configuration

XR Origin

Normally, when you play a game, all the interactions (including camera movement) happen inside the device (for example mobile, PC or VR headset like the Oculus Quest or Meta Quest for the Oculus Quest 2 Tutorial, Meta Quest Tutorial), and can be watched by the player from outside through the device’s display.

VR apps usually are called VR experiences, because they generate, well, an immersive experience.

Immersive experience means that the player feels like “being part” of the game, and in this case, also the scene.

In Unity, the camera and sound are “attached” to a gameobject called XR Origin. 

For creating a XR Origin in Unity:

  • In the hierarchy tab, right click on an empty space to create a plane
  • Click again on an empty space in the hierarchy to create a XR origin (action-based) game object

The difference between XR Origin and XR Origin (action-based) is that the first one has just the head camera and the second one also has the controllers. 

The XR Interaction Manager game object that contains the script with the same name  is automatically imported

Input Action Manager

Now it’s time to add a component to the XR Interaction Manager in order to configure input actions in our VR scene:

  • Add the “Input Action Manager” component
  • Click on the Action Assets option
  • Click on the plus button at right
  • Add the XRI Default Input Actions file

See the steps below

The hierarchy should look like this:

Left and Right Hand Controllers

In a VR device (for example mobile, PC or VR headset like the Oculus Quest or Meta Quest for the Oculus Quest 2 Tutorial, Meta Quest Tutorial), usually the player will have a headset and 2 hand controllers. 

Both Left and Right Hand Controllers must have the following actions configured in the inspector

And XR Origin must look something like this:

Testing Oculus headset and hand controllers in Unity

After following the steps above, the Unity editor is ready for checking if our headset and hand controllers are identified by the Unity editor.

At the top middle in the Unity editor, you’ll find a button with a play icon

When this button is pressed, Unity enters Play mode

Play mode is used for testing a project quickly in Unity, and this is how we will check if our VR app demo is working fine on the VR headset (for example mobile, PC or VR headset like the Oculus Quest or Meta Quest for the Oculus Quest 2 Tutorial, Meta Quest Tutorial).

If you are using Mac or Linux, you will need to compile the apk and run it on the headset. To do this, you’ll need to follow the steps described here

If you are using Windows OS, the next step is to configure Oculus Link in your Oculus device (for example mobile, PC or VR headset like the Oculus Quest or Meta Quest for the Oculus Quest 2 Tutorial, Meta Quest Tutorial). The steps required are described in the Oculus Link official guide webpage or here

After Oculus Link is installed, we can test our progress so far entering Play mode in Unity.

For this, you need to enable Oculus Link in your headset, go back to the Unity editor and press the Play mode button at the middle top. Now, go back to your headset and move your head and hands

Expected result:

Locomotion System

It’s time to move around our VR scene. Now, we will configure something called “Locomotion System”

  • Go to Hierarchy, right click and add a Locomotion System (action-based)

You should get in the inspector something like the image below while the Locomotion System is selected in the inspector

This way you have added a Locomotion System into the scene. Now we need to configure it.

Teleportation Area

It’s used for teleportation in the scene. For creating a Teleportation Area:

  • Go to hierarchy, right click and create a Teleportation Area

It will generate a new plane with a Teleportation Area script. This will be the area we will be able to teleport around.

Maybe you’ve noticed that there is also a Teleport Anchor option

The main difference is that the Teleport Area will allow you to teleport to any point on the plane, and Teleport Anchor is only for teleporting to a specific position where you point your cursor at.

For this tutorial, we will use the previous plane game object for moving around the scene.

  • Disable the Teleportation Area game object you’ve just created
  • Select the Plane and Add a Teleportation Area component
  • In project tab, create a new folder called Materials
  • Inside that folder, right click and create a new material. You can name it as PlaneColor
  • Change the material’s color (maybe green)
  • Apply the material to the plane
  • Enter Play mode and test it out in your VR headset

When the XR ray turns white, it means that the Teleportation Area has been hit

To teleport, press the grip button when the line is white

For rotation, use the Joystick button

Continuous Move

There is another locomotion system: continuous move. To make it work in the current plane:

  • Add a Continuous Move Provider component
  • Add a Continuous Turn Provider component
  • Uncheck Right Hand Move Action and Left Hand Turn Action
  • Uncheck Teleportation Provider and Snap Turn Provider

If you enter Play mode, teleportation will be disabled and you can move and turn using the Joysticks. However, this locomotion system causes something called “motion sickness” in most people, so it’s suggested to use Continuous Move Provider just in very specific cases and use teleportation instead.

VR motion sickness happens when you're moving around in a VR environment, but your body feels like it's sitting or standing in one place.

Grabbable objects

It allows you to interact with game objects in VR

  • Create a cube 
  • Modify its scale to 0.3
  • While the cube is select in hierarchy, add a XR Grab Interactable component in the inspector

When adding the XR Grab Interactable component, it will automatically add a Rigidbody, so that we can pick the cube up and interact with it in a physics-based way

For better performance:

  • Modify Movement Type to Velocity Tracking
  • Enable Smooth Position and Rotation 
  • Rigidbody: change Collision Detection to Continuous Dynamic

If you enter play mode, you’ll be able to grab the cube when the ray is white using the grip button

So far, you’ve created your first VR demo with Locomotion System and object interactions. 


Feel free to now play around and enjoy yourself using Unity’s endless features! 

I hope you enjoyed this Unity VR Tutorial (Oculus Quest 2 Tutorial, Oculus Quest Tutorial Meta Quest Tutorial). If you're a beginner, you may also want to try the free C# Coding Course to get started with VR Programming.

written by Hernando Nieto Jaramill
Reach out to us in our Discord Channel if you need more support
© 2021 XR BOOTCAMP. All Rights Reserved