So you want to build a vr game? Well, you are in
the right place and more importantly you're doing this the right time. VR is at the precipice
of becoming a major platform. We've just had two AAA video games made: Medal of Honor
and Half-Life and it's just starting to get that momentum of becoming big.
So if you're starting this in 2021, I am excited for you and without further
ado let's jump into the tutorial. First thing we need to do is open up Unity.
This project is going to work for version 2020.1 or above. We're going to use 2020.2. I'm going
to name this "VR_Tutorial". Let that spin up. First thing I'm going to do is go into scenes
and rename that to "XR_Rig_Template" so we can use this later, and we don't have to go through
this process over and over and over again. We just save one scene and then we can merge that
into other scenes that we need. Before we start adding things to the project we need to download
a lot of plugins and set a lot of settings, so I'm gonna walk through all that and then afterwards
I'm going to put a list on the screen. You guys just follow through with me and then you can pause
it and I'll show that list on the screen for you guys to just go through into your own projects and
check all the boxes make sure you got everything. First thing we need to do is go to: Edit > Project
Settings and we're going to start down here at the bottom and work our way up. So, XR Plug-in
Management we're going to install that. And then here you're presented a list of different VR
headsets that are available, but you notice that the HTC Vive isn't there, and the ones using
OpenVR aren't in here. So we're actually going to go install OpenXR now--it was OpenVR, that's
the old version and then OpenXR is the new one. And in order to do that we're going to go up to:
"Package Manager" and "Enable Preview Packages", and I understand that these preview packages
do have bugs. Exit out of settings and now we're going to go to window up at the top and
package manager and then swap this over to "Unity Registry" which shows us all of the packages that
we don't have yet--or all of the packages we do or don't have yet. We're going to scroll down until
we find the "OpenXR Plugin". Install that and one more we need to install is the "XR Interaction
Toolkit" down here at the bottom. Install that one as well. Now this interaction toolkit will
give us some samples, and we're just going to grab this "Default Input Actions" and import that
as well. And that should be everything downloaded. Now if we go back to "Project Settings" and down
here in "XR Plugin Management" you'll notice that there is an OpenXR and a features option as
well. So we can now select "OpenXR (Preview)" and then there will be this little exclamation
point that shows up. And it tells you that there's some settings that aren't correct
for a VR environment or XR environment, so we're just going to click "Fix All" and
your project's going to restart a couple times. After it's restarted there's still going to be
an exclamation point and this is telling us that we don't have a profile enabled yet. And to do
that we go down to "Features" and then you select all of the controllers and profiles that you want
to market your game to. " have tried using Oculus in this, but for some reason there's this
giant like black screen up on the side, so I don't know what's up with that. So I'm
just going to uncheck that go back to "XR Plugin Management" and select "Oculus". That's
going to download the Oculus XR Plugin, but the rest of the video is going to be the same for
everyone. That's the only like weird thing that I've noticed for Oculus as of right now. I mean
it's still--OpenXR is still in preview so there's still bugs and issues with it, so this could
be one of those that they're working on fixing. Checking "Oculus" will download the this
Oculus settings part and I just leave all of these settings normal. There's a few more
quality of life settings that we want to do, so we're going to go up inside of "Project
Settings" still, go up to "Quality" and then this "Pixel Light Count" needs to be set to one (1) and
then we're going to do "Per Texture": Textures and then "Anti-Aliasing" is going to go up to four
(4) and we're going to uncheck "Soft Particles". This really helps optimize the project. And
then there's one more little settings type thing we need to do. Inside of "Preset
Manager" you'll notice there's no presets in here yet, so we're going to deal
with this. Exit out of "Project Settings" and then when we clicked the samples for "XR
Interaction Toolkit" it put this in our project. So we're actually going to click on each
one of these and add the "Action Based Continuous Turn Provider". Add the "Action Base
Controller Defaults". So if we double click on this guy you'll see that it preloads all of the
different inputs that could be possible for any XR platform. So you got the head mounted display
position, rotation and then left hand you have all the different buttons for if you select so you
press the grip or if you move it's the 2d axis or if you activate it's the trigger pressed. And this
is for generic XR controllers, so this will work for Oculus, Vive, anything like that. But if you
wanted to add a extra button or something in here, you could add a binding and then you could click
"XR controller" and add a specific kind of input if you wanted to do that kind of thing. We
are not so, we're going to delete that guy. Back to "Project Settings" and then inside
of "Preset Manager" there was nothing, and we added all of those defaults in here. And we
need to specify which controller for the filters, so we need to type "Right" in here and
then "Left" in this guy so they line up with the correct controller. Now
all the settings should be correct. And we can start adding things into our
scene. First thing I'm going to do is make an "Environment" game object. Add the directional
light into that. Add a 3d object plane, call that "Ground". Set all of these to
"Static". And now you're able to right click, and then inside of "XR" we can add a "Room Scale
XR Rig (Action Based)". Action based is the new input system. Device based is the old system that
they're phasing out. I don't know how long they're going to support that, but "Action Based" is what
we want to go for. So default is "XR Rig" and then inside of this XR rig you get a camera offset and
then you get a main camera, left hand controller, and a right hand controller. There's one
thing that the preset XR rig doesn't have and that's a Component > "Input Action Manager".
So just search "input". I'm going to add that in there, and then we're going to add one (1) "Action
Asset" and the default input actions that we specified. Now your controller should be set
up, and if we hit play we'll see what happens. So now you're able to move around. These little
laser pointers are connected to your hands and then you should be able to move your HMD
around and there we go. That is the basic setup. Congratulations, you have started a
project. I'm going to show you two more things in this video. I'm going to show
you how to pick up things, and I'm going to show you how to move around the space. Those
are the arguably most important parts of VR, so let's get into that real quick. Picking things
up is super easy. So inside of our "Environment" we're going to add a 3D Object > Cube. Move
this guy up a little bit. Press "R" and then size that up. Set him to "Static", and then
we're going to add another 3D Object > Cube. Reset the transform on that. Press "W"
to get the position. Press "R" again. Scale this down to somewhere in the point
ones (0.1s) is always a decent size. Move that so it's right here on this
little table. So this is currently the default cube. In order for an object to be
grabbable by XR, we need to add a component. And then we can scroll down here to "XR" and then
we're looking for the "XR Grab Interactable". And this will add a "Rigid Body" and it
will add a "XR Grab Interactable" component. Now you should be able to
pick it up, so let's try it. Now when you point at the cube--it's
not a good color--but you can see, if you point at the cube your laser pointer
turns white and if you press the grip, the cube will come to your grip and
then you can swap between hands. And you can throw it too. And it's a distance grab--it's a distance grab so anywhere your laser
touches you can reach out and get it. There's a few cool things you can you can play
around with inside of the "Grab Interactable". One is the "Throw Velocity Scale". So if you bump
this up you can throw objects super far, like just launch things. And then the "Attach Ease-in Time"
is how quickly it takes from when you're pointing at point at it and grab it to it actually being
in your hand. So you can create some pretty cool like low gravity almost effects by bumping that up
and then it just kind of slowly turns and rotates up into your hand which can be pretty cool. Feel
free to play around with those. Last thing we're going to do is add a "Locomotion System". So
inside the "Hierarchy" I'm going to right click, go to "XR", and then "Locomotion System".
And it presets your locomotion system to be teleportation and snap turns, but I don't
like teleportation as much. I think it's just--it just feels gimmicky. It's not super fun. If
you can handle the motion sickness, and inside of your game there's a few things you can do to
counter the motion sickness of a continual move. A couple of those are: moving slow, so the slower
you move the better. Or being off the ground, so the higher you are off the ground when you
move the--. What causes the motion sickness is you see the ground going by you, but your body's
not moving, so if you push the ground down you don't see the ground moving by you and your brain
doesn't think that it's-- like it doesn't really get motion sick. So we're going to remove the
"Teleportation" component and we're going to add--. We can go down here to "XR" > "Locomotion"
> "Continuous Move Provider (Action Based)". And the locomotion system is itself. It
defaults with both controllers being able to do both actions which is going to get really
confusing, so we want to uncheck-- so we want snap turn to be on the right controller
move to be on the left controller. I'm going to uncheck the appropriate
ones for those. And now when we hit play. You should be able to move around. So
snap turn with your right controller there's a delay in there so you can't
just spam it. You can adjust the delay. And then you can also do a continuous move. Now in order to use this XR rig in other
projects, I recommend saving it as a prefab. In order to do that I'd take "XR Interaction
Manager", throw that into XR rig and your "Locomotion System". Put them both in the XR
rig and now you can save this as a prefab. So inside of "Assets" we can create a folder
for "Prefabs". And then just drag this down into there, and now you have a setup XR rig prefab
that you can just drag and drop into any of your projects. And you have a setup movement system,
an action system and all that kind of stuff. So there you go. You see this face? This is the face
of pride. I am proud of you for finishing that project. In all seriousness, I am super excited
for you to be starting VR development. It's a crazy world and it's gonna be amazing. I would
love to hear how this went for you. Please don't hesitate to add to the comments. If you run into
any issues or roadblocks please ask questions in the comments too. I personally will answer and
help you guys out, and if not me there's plenty of super smart people who watch this channel who
will also help you out. So don't hesitate to ask questions and jump in on the community. If this
video has brought you value in any way please don't hesitate to subscribe. It really gives me
the motivation to keep doing these videos. More VR tutorials are already in the works. I'm already
working on some more stuff for you guys, and I'm planning on doing some detailed step-by-step
walkthroughs of how to actually develop major games like Beat Saber or Super Hot VR and
basically just replicating-- doing several hour long videos about step-by-step how to replicate
these games. Just so you guys can learn. I learn by replicating. That's kind of how my process
works, so I want to provide you guys with some of the same tools that I need in order to learn. If I
could watch a step-by-step guide about how to make Beat Saber or how to make Half-Life VR... That
would be amazing. So I'm gonna provide you guys with some of that content. So subscribe for these
upcoming videos and I'll see you in the next one.