Skip to content

Create a VR GAME in 2021

VR
Lost in coding? Discover our Learning Paths!
Lost in coding? Discover our Learning Paths!

Are you interested in making a VR game? Then this video is a MUST WATCH for you!

By the way! If you are interested in becoming a professional software developer, make sure to check out our courses!

And find the video to this article here!

How to create a VR GAME in 2021

A VR game, one of the most interesting new concepts of technology in videogames, but oh so scary to try and make. Well, I think we can help with that.

Today, we are making a VR game. Let´s get to it.

 

VR  PROJECT CREATION

First, things first. Let’s create a new project, we’ll be using 2021.1 today but you should be able to mostly follow this step by step guide with any Unity version, although, I do recommend using the same one to avoid issues.

So, click on new,  just select the basic 3D project and name it something like VRMasterpiece, perfect.

VR

VR PROJECT SETUP

Once in project, start by installing the required packages.

First, go to Edit>Project Settings>XR>Install. Give it time.

VR

Now, this gives us some plugins for some of the things we could need. But we, to make our system as cross-compatible as possible, will be using Open XR.

So just click on Open XR and this should start downloading everything you need

Click on yes on the pop-up. That’s just letting you know that open XR will be using the new Input system. We’ll be making a video on that soon as well so make sure you subscribe to not miss it.

It’ll take a while and restart, just wait until it’s done

Ok, once done, you’ll get a little warning sign besides OpenXR, click on it and you’ll see that it isn’t more than just some setting configurations that are missing.

Click on Fix all to take care of that

Ok done. Now we see that we are left with still one more warning. This one just means that we still need to configure a profile. So let’s do that.

Press on Edit and it should take you to the OpenXR options, also down here. In here, you see the interaction profiles.

Here you can choose basically what platforms you want to market your game towards. I’m going to choose Oculus since that’s the headset I have.

Ok, that’s that for Open XR. Now a warning, for the quest users out there, we will need to use the oculus plugin here for the environment itself, OpenXR is correctly installed but if we just tried running it on our quest as is, it basically just isn´t going to work. Maybe for your version it even works already so you might not even need to do this but. Let´s just do it here because I already know that mine will break.

So, Uncheck OpenXR and check oculus, this will install everything necessary for your oculus system and you can just move on.

Don’t worry though. You can still use Open XR in any other situation and the rest of the tutorial will be exactly the same as well, you just need to have this checked if running on a quest.

Well, let’s get now the XR Interaction Toolkit. You can find that in Package Manager

First though, depending on the time you watch this video it might not be needed anymore but you will need to enable preview packages. For that go to Project Settings, and select inside package manager, enable preview packages.

Inside package manager, select Unity registry and search for XR and you’ll find it there. Click install.

To make this tutorial simpler, make sure you download Default Input Actions as well.

Now. let’s go to project settings again and see how our preset manager is doing since this will be using presets to work.

As we can see, it looks a bit empty, now, since we imported the default actions, we can easily populate the presets.

Just go to Assets>Samples>XRInteractionToolkit> And just all the way down until you reach these.

Now, make sure you Add all of these to ActionBasedContinuousMoveProvider default

And now when we open our input actions, we can see that it prepared all the different inputs for the different XR systems we might need.

Ok! So close out of this since it´s already prepared and now you can see how all of our new presets are added to our preset manage automatically.

There´s just one thing you have to do here, and that is to specify the hand used for each controller, so just Right here and Left here. Done.

SCENE SETUP

So that´s was it for the initial config. Let´s now get to actually adding content to our scene

Add plane

Set its transform to something like this

Add XRRig Action based

XR COMPONENTS

Add Action manager component and action asset

And there we go, play and magically it just works

Technically that would be it. That would be the beginning of a VR project on which you can easily expand upon. But since this was so quick and easy, let´s throw some bonus content in here.

XR MOVEMENT

Let´s start with movement. For that, go to your hierarchy and right-click XR>Locomotion system (action based as well) THis will basically already give you premade controls for the most typical locomotion system in VR

In this case it´ll set it up with teleportation and snap turns. Which is a yikes. Big yikes even.

So just remove the teleportation and Snap turns

Add Continuous move provider action based

And continuous turn provider action based

Add locomotion system

Now select what you want to do with each controller. So move with left controller, uncheck right. And turn with right controller, uncheck left.

Now just play

And there we go. Movement and camera controls all working perfectly together.

You know what? I´m going to add one more thing to this. This has been way to easy.

XR GRAB INTERACTION

Let´s give the ability to grab stuff.

For that, create a little cube and turn it into some sort of a table here. Add a sphere, reset and place on top of the table. Make it a bit smaller.

Now add a rigidbody and a sphere collider to it.

Now. literally for the last step. To make it grabbable. Just add an XR grab Interactable component to it.

Let´s try it out

CONCLUSION to VR Project Creation

And that´s it. Your VR system just works now. Flawlessly. In less than 20 minutes. So what are you waiting for, use what you created and build on it, make the VR game of your dreams.

Before leaving though, remember check out our YouTube channel for the video version of this Post, and our subscription to get access to all our courses to help you become the Software engineer you ´re aiming to be.

Bye!

Lost in coding? Discover our Learning Paths!
Lost in coding? Discover our Learning Paths!
Enter your email and we will send you the PDF guide:
Enter your email and we will send you the PDF guide