Introduction to VR in Unity - PART 1 : VR SETUP

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
making a via game stuff from the code the game on Jang Viet set the motion sickness there are so many factors that a developers need to take into account and can feel overwhelming when getting started this is why I've decided to create a complete tutorial series that will teach you all the basics you need to know to make a VR game it won't need any knowledge about code or game engine and will work for all modern VR headsets and I have the pleasure to let you know that you're watching the first episode where we will learn how to set up a project from scratch i'm verum and this channel is all about VR development so if you don't want to miss the next video make sure to subscribe and ring this notification better also if you want to learn more advanced subjects an extra episode on my patreon where you can support this channel but without further ado let's jump right in the tutorial so what do you need to make a VR game you will need three things a VR headset a game engine and a software development kit or SDK in short for the ad set I'm sure you've already made your research but as a VR developer there are two main element that can impact the development first is the VR headset a three degree of freedom or six degree of freedom secondly is the via exit stand allowed or is it connected to a PC this tutorial series will work for all kinds and I will guide you if some element are specific to one the second thing is the game on join a game on Jang is a development platform that can handle all aspect of the game like the physics or the graphics there are multiple game enjoying that are free to use like unity Unreal Engine or gadot but for this tutorial series we will stick with unity this really is a profound choice all these resource are viable but unity is flexible as a huge community lots of documentation and is on page with VR which makes it really great to get started for the third element this is where things get tricky so bear with me SDK is what will end us specifically in the VR asset if you're familiar with this channel you already know two of them steamvr and the oculus integration which I previously made a tutorial series about on this channel and are really great plugin however the problem with them is that these are dependent from the ad said that you use which is that really an D because it means that if you have via game and that you want to make it work for several at set well you can't but lately unity has introduced their own via plug-in management tool which integrate all this platform in one single place one SDK to rule them all and in the darkness bind them and this is what we will use for this tutorial series as it is the most flexible and as its unity own solution we can expect it to work for a long long time which is a great news for beginners okay so enough with the talking now that we know more about what tools to use let's get to work the first thing I'm going to do is download the Unity game engine we can go to unity 3d comm slash get unity slash download which you will find a direct link in the description below and click here on the download unity hub now that the hub is downloaded we will download a new version of unity so let's go to the install panel you can see here all the version of unity I have already installed on my computer now to install a new version let's click on add for this tutorial series I will use the two times a 19.3 version of unity if you're watching this from the future which technically everybody is make sure to select an official version above or equals to 2019 to 3 if you have any doubt about the version I will leave a pin comment below with all the information or change that might happen with this tutorial so if you stuck at instep of these tutorials go check it out now let's click on next there you will be able to download additional modules for your game so if your VR headset is not connected to a PC like the oculus quest or the oculus go make sure you select the Android build support here which will let you export your project on these types of devices once ready let's click on down and there you go we now have unity in style now let's create our project first let's go back to the project panels there click on the little drop down icon next to new and make sure to select the version we've just downloaded we can give a name to our project and set a particular folder to store it in my case I will name mine my first vr game really original I know now as you can see you have multiple choice on the left side for this project we'll go with the universal rendering pipeline as it gives more optimized graphics which is good for VR now that we're ready let's click on create by the way always before launching your project take the time to make sure that your headset is working properly if you have an oculus request with an oculus Inc make sure it's plug and if you have an oculus device like I do make sure you have enable in no source by going to settings general or no source that will let you use your oculus device outside the oculus store to test it directly in unity Tara we are now in an empty unity project a world of splendor as just open in front of our eyes so as you can see the Unity game engine is cut into several windows you might not see the same placement of them as I do but that's just a preference I found out that I work faster like this but if you want to have the same one as me an easy way to do it is to go here on the top right corner and click on layout there you can find some windows presets and if you want mine you can click on toll and drag the game windows tab to the bottom over there now the seen window here is your good MIRR view that you can use to watch what you have in your game at any angle for example you can click on the middle mouse to pan or maintain the right-click to look around and even combine the right-click with the arrow key to move around the game window down there is what your player will see finally the Yaqui contains the list of all the elements present in your scene for example if I go in the the example assets I can see that we have some props in our scene like this paint bucket which I can double click on it to zoom all element in our scene F transform data that we can use like the position the rotation of the scale and that you can edit right here in the inspector tab as you can see the inspector contains all the component on each game object but an easier way to edit an object is in the scene windows with the transform tool so pressing W for the moving to e4 the rotation tool and R for the scaling tool and there you go that's basically all you need to know to make things in unity easy right now that we are all ready unity expert let's do the setup for VR so I will make my VR game in another thin as I don't want these elements in it to do this let's go in the project windows over here which contains all the data that we can use in our game as you can see there is already a pre-made folder for the scene that we can go to to create a new scene I will right-click go to create scene I will name mine VR bullying you will see why at the end of this tutorial once created we can double click to open it and there you go we are now in a fresh unity scene to setup VR we need to install some packages so let's go to windows package manager wait for all package to show up and search for XR interaction toolkit if you don't see it make sure to go here in advance and select show preview package man selected click on install okay we are almost done last thing we need to know is say on which device we will use our game to do so let's go to edit project settings and click on X our plug-in management this is the new unity X our plug-in that I talked about earlier and that allows us to build on multiple devices to use it click on install X our management as you can see we have now the possibility to add all the types of devices we want for our game for PC or standalone Android devices in my case I think I will select oculus and Windows on PC and oculus on standalone devices but you might realize a little programmer right here there is no SDK for open VR devices like the HTC vice or the valve index for example as unity mention in their blog post valve is currently working on it and this will be added very soon I contact them and will let you know in the pin comment below as soon as I get the information so if you're building for these devices and that you don't want to wait there is an easy workaround first make sure that the version you use is 2019 the three like mine and unselect all the previous selected SDK go to player tab you will see that we have some settings for each platform with install and on the bottom of the tab we have XR setting here with a message saying that this will be duplicated in future versions so that's the reason we need to stick with the 2093 for this workaround now let's check the virtual reality support checkbox and we will be able to add the SDK for open VR and oculus Iran the same place and if you're going for this method and want to build for oculus quest make sure to enable it in the Android player settings either way if you're going with this workaround or with the new XR management the rest of the tutorial is the same so don't worry pew okay that was it the boring part of the tutorial is not complete we have now everything ready to work on the phone part the game so let's make this happened I will first start by creating a ground for game to do so I will right-click in the ER key go to 3d objects and click on plane and now we have a plane on our scene make sure to set its position at 0 0 0 we can even increase its size by pressing on the are key and scaling it up here you go I will also change its color to black to do this let's right click in our project windows create and click on material I will create black and change its color over there - well you get it black now I can simply drag the material in the scene windows to the plane we made now let's set up the camera for the player first I will delete the main camera we can right-click on it and click on delete as we don't need it now to set up the camera we need to create a zone where the player will move which is known as the VR rig or the play area so I will right click create a new empty game object call it VR rig make sure to set its position at 0 0 0 now on this empty game object I will add a new component called XR week by first clicking on add component and searching for X our rig you go by the way if you're asking yourself why most of the stuff are called XR and not VR it's because XR is the combination of augmented and virtual reality and fun fact all the element here can be used for AR but this is the subject of another video as you can see we have two element missing in the script a camera floor offset and the camera itself this is what we will add now first let's select the X our rig and create an odd empty game object this will set it automatically add a child of it make sure that its position is at zero zero zero now for this new game object let's call it camera offset then I will right click again on this camera offset and create this time a camera we can name it via camera and so the camera will be the player's eyes and need to follow the add rotation and position to make this happened we can add a track post driver component to it which does exactly this job and you go as you can see we can decide to make this game object follow the headset or controller and choose the source of the tracking but in my case I will leave it to follow the headset on the center of the eyes and there we go now what's left for us to do is drag in the XR ik what we just made so the camera offset for the camera offset variable and the VR camera for the camera variable and there you go our setup is completed let's click on play to test our game nice work now VR is working properly as you can see I can rotate my head and it will rotate accordingly in the game awesome we can even maximize the game window for us to see better if at the state of the development VR is not working it either means two things either your VR at set is not set up so save your scene with ctrl + s quit unity make sure your headset is working and then we start your project or it means that you don't have a device that can test VR directly in unity which is the case for the oculus go or an oculus quest without an oculus link so in this case you will need to export your project to test it and this is what I will show you at the end of this tutorial but back to of your setup there is one more problem here as you can see we are at the floor level so to fix this we have to solution first is to increase the ID offset on the camera offset or the other one is to use eye tracking which works with six degree of freedom at set and can be done by setting the tracking origin mode to floor let's click on play an eery go now I'm at the good size okay so this works for the headset now let's make the tracking on the controller first I will create two new empty game object under the camera one call left hand and the other right end and to make them follow our controller we could use the track pose driver as we did for the camera but in our case we will use something better provided by the X our toolkit the X our controller component so let's select both click on add component and search for X our controller perfect now for the left hand I will select the control node to left end and for the right end you guessed it you we can set it to right and nice so let's click on play to see what we've made okay so our ends are moving as we can see from their position changing in the inspector however we cannot see them because well we don't have a visual for them to add a visual tour ends we can use the model prefab on the exact controller component a prefab is basically a game object that is safe in our project so if you wanted this is where you could drag a model of a hand or a VR controller for example in my case I will create an empty game object call it via controller create a new cube as a child of this empty game object and scale it down to let's say five centimeters lengthen it on the blue axis and create a new white material to paint it to this color now to make it into a prefab we simply need to drag it in our project folder and there you go you can see that it is safe in our project over there we can now remove the one from the scene and drag the one that we saved in the VR controller of our left end and right end and now we can click on play and there we go we now have a VR controller showing awesome and basically that's it we now have finished off we are set up what we have here is a VR set up that can work with any VR headset and that you can use to build upon for your next project but as we have some more time I want to show you what can be easily achieved with it so first let's create a cube I will scale it along one axis and place it next to the player this cube will serve us as a table now I will add this time a sphere scale it down and piss it above the cube we can create a new material for the sphere that I will call red and set its color to red perfect now I will add a rigidbody component to this cube a rigidbody will let the sphere of some physics properties like gravity according to its collider which we can see over there so let me show you how it worked by clicking on play as you can see the sphere Falls and I can even play with it with my n but I cannot grab it for the moment and this is what we will do now to grab a sphere we need two things first we need to add to the sphere the X our grab interactable which will let us grab it secondly let's add back to our controller and this time I will add on both of them a mix our direct interactor that will let us interact with object I will add a sphere Collider scale it down to 20 centimeters and set it to trigger this will create a trigger zone that can be used by the X our grab interactable component to know if we are interacting with an interactive object and there you go everything is now already I can now approach my ants to the ball and if I press on the grip button we are grabbing the ball awesome I can even switch my arm and threw it there are just little issues that I want to fix right now if we put the ball close to add you can see that it disappears we can easily fix this by going into our VR camera and in the camera component under projection we can reduce the near plane to may be 0.1 so that it will allow to render object on this distance perfect much better like this so we can grab a ball you know what's tough to do that's right create a bowling alley let's create a new cube skidded along the blue axis and put it in front of the player a bit elevated like this for the bowling pin I can create a cylinder scale it to an appropriate size paint it to white and add a rigidbody you go let's duplicate the pin with control D if we want to get good physics let's maybe increase the ball mass to seven and there you go now if we press play we can grab our heavy bowling ball and play or so on and there you have it we finish our VR setup you have seen the basics of VR development a basic setup with AD and controller tracker that works for any VR headset and basic interaction now if you want to export this game outside of unity in an executable file that you can share it's really easy just go in file build settings if you don't see our VR bowling scene click on add open scene and maybe remove any other thing next if you are on a PC what's left to do is click on build and run and you're ready to play your game but if you need to export on the standalone device like the oculus go or the oculus quest select ear Android and click on switch platform and now you're ready to click on build and run but if unity doesn't see your device it means that it's not in developer mode yet so first make sure that you enable this mode in the oculus app like it's the case for the oculus devices then plug your asset to your computer hello everything if you have a message popping and there you go you can now export correctly anyway I hope you enjoyed this tutorial as much as I did making it if you did please leave a like below and share this video to help your friends in the next episode we will learn about input system and how to move with continuous movement and teleportation so subscribe ring the notification bell to not miss it as mentioned in the intro if you want to add the channel and get access to exclusive content where I will show more advanced stuff you can go to my patreon and support the channel on this subject a big shout out to my new patreon the name will appear in the right corner of the screen anyway thank you for watching and see you in the next one
Info
Channel: Valem
Views: 443,634
Rating: undefined out of 5
Keywords: Virtual Reality, Unity, VR, Valem, how to make a virtual reality game in unity, virtual reality unity tutorial, oculus tutorial unity, oculus quest unity, Make your own game in Unity, vr tutorial beginner, introduction to vr development, VR basics tutorial, how to make a vr game in unity, XR Toolkit unity, XR tutorial unity, beginner xr tutorial, vr unity beginner, vr unity basics, unity vr tutorial 2020, how to make a vr game, xr unity tutorial, unity xr toolkit
Id: gGYtahQjmWQ
Channel Id: undefined
Length: 20min 36sec (1236 seconds)
Published: Wed Apr 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.