Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.

com/unity-vr-tutorial-for-beginners/

XR Tutorials

Easy Unity VR Tutorial for Beginners


By XR Bootcamp | February 17, 2022

Installing Unity and modules

Installing Unity Hub

Installing Unity

Adding Unity modules and Script editor

Creating a new project

XR Settings con�guration

1 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

Scene con�guration

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 �rst 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.

2 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

After the �le 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

• Select the installation folder

3 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• Click on Finish to start Unity Hub

A new window like this should appear. 

Let me introduce you to Unity Hub!

4 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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 �nd the editor versions that can be
installed.

5 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

6 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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?

7 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

8 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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 con�guration
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 con�gure 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

9 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• Click on XR Plugin Management (bottom left)


• Click on Install XR Plugin Management

10 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• 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.”

11 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

What is OpenXR?

• It’s a standardized interface that allows you to con�gure 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

12 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• Click on Edit
• Select the Oculus touch controller pro�le as shown below from the new window

• Interaction pro�le: type of con�guration 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

13 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• Select Oculus option below XR Plugin Management. It should look like this:

Con�guring 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 identi�ed by the game engine editor
(Unity) and will “trigger” or execute some other actions in the program,
application or game. 

One example is �ring. 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 con�gure the XR Interaction toolkit, a framework that works pretty
well with OpenXR.

Installing XR Interaction Toolkit

14 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• 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

15 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

These Default Input Actions are pre-con�gured 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 �les (except by the �le with the blue ray):

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

16 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

17 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

Scene con�guration

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

18 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

19 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

The difference between XR Origin and XR Origin (action-based) is that the �rst 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

20 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

Input Action Manager

Now it’s time to add a component to the XR Interaction Manager in order to con�gure
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 �le

See the steps below

21 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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 con�gured in the
inspector

22 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

23 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

And XR Origin must look something like this:

24 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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 identi�ed by the Unity editor.

At the top middle in the Unity editor, you’ll �nd 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 �ne 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

25 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

If you are using Windows OS, the next step is to con�gure 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 o�cial 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 con�gure something called
“Locomotion System”

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

26 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

27 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

This way you have added a Locomotion System into the scene. Now we need to
con�gure 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

28 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

29 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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 speci�c position where you

30 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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

31 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

Company
Legal
Home
About XR Bootcamp
Programs
Impressum
Scholarship
Privacy Policy
For Companies
Contact
For Universities
Förderung
Careers
• Enter Play mode and test it out in your VR headset

© 2021 XR BOOTCAMP. All Rights Reserved

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

32 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• 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 speci�c 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

33 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

• 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

34 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

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 �rst VR demo with Locomotion System and object

35 of 36 11-03-2023, 14:05
Easy Unity VR Tutorial for Beginners - Step by Step Guide https://xrbootcamp.com/unity-vr-tutorial-for-beginners/

interactions. 

Awesome!

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.

Reach out to us in our Discord Channel if you need more support

36 of 36 11-03-2023, 14:05

You might also like