How to Make Oculus Quest 2 Games // Introduction to Unity VR Development

In AR/VR Development


How to Make Oculus Quest 2 Games // Introduction to Unity VR Development - read the full article about VR development, AR/VR Development and Augmented & Virtual Reality Solutions from Justin P Barnett - VR Game Dev on Qualified.One
alt

i just recently got this beautiful oculus quest  over here and im gonna use it to make my own game the first video i have on this channel is  how to make a vr game in 2021 and its using the oculus rift s which a decent amount of people have  but i just recently got the quest 2 and the setup for that is a little bit different so im going to  remake that video and show you guys how to set up to develop with the oculus quest 2. lets go first  thing we need to do is download unity if you dont have that installed already you can just type in  unity download into google and this first link will get you there were gonna download unity  hub and then choose the version from that when it first comes up youll be greeted with this  little setup window right here go down to the installs and if you dont have an install already  were gonna click add and then choose the latest long-term support version and that is the  recommended version that you can grab you can go newer if you want but these are still being  developed on so my recommendation is always to go with the latest long-term support version  so for this im using 2020.3.5 keep in mind you can have multiple versions downloaded at the  same time so you can swap back and forth so im just gonna download the 2021 version go hit next  and then if youre using the oculus quest 2 you need to make sure you have android build support  checked because the oculus quest 2 is inherently an android device if you want to build games to it  and actually run games on the quest 2 youll have to have android build support checked make sure  you agree to the terms and conditions hit continue approve it on your computer and let that run for  forever once your version is installed itll look like this one over here and if you have the  android build support thatll show up in the little android thing down here so if we want to  start a new project were going to go over to projects you can click on new here or if you have  multiple versions you can click this drop down arrow and select which version you want to create  a new project for from here you can choose any number of templates theres even a vr template but  ive found that it works better when i just start with a from scratch universal render pipeline or  3d template and then build up from there i found that the vr template doesnt actually get you  to the place im trying to go as far as using openxr and that kind of stuff so universal render  pipeline is my go-to because it comes pre-built with a little bit of a scene and the lighting  pipeline is a little bit better im just going to rename this to like quest 2 and then create while  thats spinning up lets open up the oculus app on the pc go over into settings and then click on  general and make sure unknown sources is true over here and then were gonna go to devices and  if you have multiple devices youll need to make sure that your quest to is the active  device so make sure to turn it on and youll see here that it is now the active device but  if you wanted to swap it over to active you click on it and then click this button that  says set as active and then were going to put the quest 2 in developer mode so to do that youre  going to need to go to the app so with your phone or ipad or something open up the oculus app go  over to settings make sure you select the quest to connect to that and then click on more  settings and then developer mode and make sure developer mode is selected this lets you  add unverified apps onto the quest 2 so all of our development can be added and built onto the  quest 2 without facebooks permission now we can jump back into unity and see that we have our new  universal render pipeline project first thing we need to do is go into edit and then project  settings and then inside of settings were going to go up to package manager and check  this box that says enable preview packages and then check that i understand this lets you  download packages that are still in preview and not pushed out to the 1.0 version exit out of that  now were going to go up to window and package manager right up here at the top next to this plus  icon were going to click on packages in project and change it to packages unity registry and then  scroll kind of to the middleish and find open xr plugin and click install the openxr plugin is  the platform that allows you to create a project have one input system and it will work on any  device so itll work on oculus devices valve vive any other vr hardware devices youre going to get  this pop-up that says do you want to restart and its going to swap your input system from the old  device-based legacy system over to the new input system so were going to say yes your project  is going to restart if you havent saved itll prompt you to save and then the project will shut  back down and open back up and then still in the package manager were going to scroll all the  way to the bottom and find the xr interaction toolkit this one at the moment is still in preview  so thats why you need to enable preview packages so you can actually see this part were going  to install this and this comes with a lot of pre-built input actions and locomotion and that  kind of thing to move the player around and a lot of scripts that we dont have to write ourselves  were also going to expand samples and import the default input actions this will set us up with  all the controls we need to set out with instead of actually writing them all ourselves and then  one more thing lets go back into edit project settings and we want to go all the way down to xr  plugin management so now that you have the android platform installed youll see theres an android  tab and theres a pc tab so just like all the other tutorials were going to check openxr for  the pc tab click on the exclamation point check fix all and go into features and check oculus  touch controller profile still in the pc tab then were going to go back to xr plugin management go  over to the android tab and check on the oculus ive tried this with the open xr plugin but the  issue i keep running into is when i try to build in the headset it comes up as a flat screen almost  like im watching a movie instead of actually putting me inside of the project so in order to  actually test out the project and build to the quest to youre going to want to use the oculus  plug-in instead of open xr and by checking this oculus plug-in it will automatically install that  plug-in and youll get this other option down here for oculus where you can adjust these settings so  just make sure your target devices the quest 2 is checked lets exit out of this and go back into  the scene and start to set up our xr rig so the default universal render pipeline project comes  with this little construction scene i always think that the gizmo icons are way too big so  im going to scale those down so before we add this xr rig were going to add the default input  presets those are going to be located in samples xr interaction toolkit whatever version that you  downloaded and default input actions so click on each one of these presets and then up here at  the top in the inspector just click add to action based controller and this will automatically  populate the correct controls for doing locomotion snap turn teleporting all that kind  of stuff if we double click on this xri default input actions youll see that its pre-populated  with all these different actions so with these added it will automatically track your position  rotation the select which is your grip button activate which is your trigger button ui press  and all these different actions here so we dont have to go through and set these up manually you  could if you wanted to you could add by pressing this plus sign up here and add a new action with  your specific controls by going into the binding and going down to xr controller and selecting  your specific controller and what buttons you want there so thats how you add a new action but  were just going to use the default ones for this if youre interested in a little more detail about  this kind of stuff i have a whole nother tutorial specifically about how to use unitys new input  action toolkit so if youre interested in more information about that ill link it up here at the  top after weve added all these presets theres one more thing we have to do in the settings were  going to go to edit project settings and then find preset manager and youll now see that this action  based controller will have two presets one for the right controller and one for the left controller  and then youll also see the continuous move turn and snap turn so these are all the presets that we  added we need to differentiate the right and left controllers so in order to do that were going to  write right and left inside of this filter column and that will help unity understand which one  goes where i dont know why i cant just get it from the preset name but this is how it wants to  do it so lets add our xr rig were going to right click over here in the hierarchy go down to xr and  then click on the room scale xr rig action based if youve moved your camera on the scene at all it  will probably show up weird and not in the right spot you can see its down there in the corner  so im going to go up to transform right click and click on reset and then ill put it back in  the center of the scene and then i can reposition it wherever i want so this box is going to  represent where the room space is not necessarily where the character is essentially where the  player is going to be able to walk around inside of their room so if youre building a room  scale game where the player doesnt actually move all they have to do is walk around in the room  you want to confine all the things that can be interacted with inside of this box and by the way  if you dont want to set up all of this and run through the build settings that were about to set  up and do all of these things then you can just download this project if you want to support me  on patreon ill link that down in the description and you can just download the project and be  set up to run on quest 2. i really appreciate all the current Patreons that are the whole reason  that i have this new quest too so thank you guys so much and lets set up the build settings and  finish this out we want to add one component to the xr rig to be able to operate it click on add  component and type in input action manager add that one and then under this action assets there  isnt going to be anything in there right now click on this xri default input actions and drag  it over and thatll put that as the element in there and now you should be able to control the xr  rig so theres two ways you can run your project in the quest 2. one of them is exactly like using  the rift s or any other linked headset to your pc all you have to do is hit this play button up  here and make sure your quest 2 is in linked mode so youll need to click on settings go over to the  quick actions menu and then click on the enable oculus link and that will set you up so whenever  you hit play in unity it will automatically run that project on the quest 2 without having to run  a build or do any of that thats the fastest and probably the most recommended way i would suggest  the other way you can test your project on the quest 2 is by doing a build and actually putting  it on the quest to and this will enable you to run your project the unlinked untethered but it  does require building your level every single time you want to test which is a little more time  intensive but ultimately may give you better testing results so its kind of a pro and con do  you want to test it fast or do you want to test it well kind of thing in order to do that were going  to mess with the build settings so go over to file build settings and then we want to add open scenes  so whatever scene you want to test make sure its up here in the scenes to build and then you can  check and uncheck the ones you want and then click on this android here and if its not downloaded  like we talked about at the beginning youll have an option to download the android build support  and if it is downloaded it should look like this all we have to do is go down here and click on  switch platform this may take a minute its going to go through all of your configuration settings  and swap them over from pc or mac to android there we go we have an option to build or build and run  down here at the bottom first were going to click this default device and swap it over to the quest  2 because thats what we want to build on and then in order to build it and push it over to the quest  2 youre going to want to make sure your request 2 is on and connected via a link cable and then  you want to click on build and run its going to prompt you to write a name for your project so  im just going to call this one test quest 2 and then if this is your first time doing a build its  going to take a minute so it hasnt pre-built all of the lighting settings or anything so depending  on how big your level is its going to take a several minutes but then your subsequent builds  are going to be a whole lot faster because itll cache all of that information from the first  build the reason i checked build and run instead of build is because build and run will actually  build it and then put it on the quest too if you just click build its going to create a file but  its not going to put it onto the quest 2 and its not going to run it so you would have to do that  manually so just clicking build and run skips some of those steps and makes it easier there we go now  im going to pull up the quest and run the project so all i did was put the headset on and it asked  me to turn on my controllers so i hit continue and it threw me into the app and now everything is  working just as expected the lasers are tracking to my controllers and i can move my head around  in 3d space now in order to exit the app all we have to do is press the home button on the right  controller the oculus button just hold that down and then we have the option to quit and thatll  take us back home and if i want to get back into that build without having to run another build all  i have to do is press on the oculus button were going to go over to apps click the all drop down  and then scroll all the way down to the bottom of unknown sources and then all of the builds that  you put on are going to be in here unknown sources and having the quest in developer mode allows  me to have access to this folder here so this one was called quest 2. so if i want to rerun that  all i have to do is click on it and thatll drop me back into the project get a nice little made  with unity sign and here we are and just for good measuring im gonna test running the quest in play  mode so if we go over to unity first we need to put the quest into link mode so im gonna click  on settings go to quick actions menu and then click on the oculus link button and thatll put  me over into the link mode oh its saying my pc got disconnected so im just going to unplug  my cable and re-plug that back in its going to ask me to allow access and then oculus link is  available in settings so im going to go over here quick actions menu and then oculus link that puts  me over into link mode and now i can go to unity and just hit this play button here and it should  run the app over in the quest um it lost tracking on my controllers for a second so i had to just  click on the buttons and uh now its tracking everything and i can move my head around and move  the controllers around and everything works and from here i could debug inside of unity so i could  use unity and you know go over into scene mode and debug everything thats happening whereas  if i actually build and run it in the headset i cant see whats happening over in unity so if  youre debugging or just you know doing major game development i would highly recommend using a link  cable and just running it as if it was a rift s or a plugged in device there you go now you can  develop games using your oculus quest too and i look forward to seeing what you make if you  make something cool definitely add a comment and tag me in it or join the discord and you  can show off in one of our channels if you have any questions or if i didnt cover anything  quite to your liking definitely add a comment i reply to every single comment in the comment  section so lets chat and uh until next week

Justin P Barnett - VR Game Dev: How to Make Oculus Quest 2 Games // Introduction to Unity VR Development - AR/VR Development