How to Make a VR Game WITHOUT a VR Headset

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is up vr nerds welcome back to a new video so in this video we're gonna take a look at something a bit special how to make a vr game without a vr headset either if it's because you don't have one with you or simply to speed up the development time or even because you don't want to mess with your air today you will see this as plenty of great uses so without further ado let's get started and make sure to subscribe and ring the notification bell to not miss the next video okay so i'm in an empty unity project right now i've simply downloaded the unity xr toolkit in the package manager and that's it now as you might already know to complete the setup for vr we need to enable it in the player settings and we have two ways of doing that either the old way for version below 2019.4 or the new way using the new xr plugin manager for version above 2019.4 now if we do the old setup by going to the player settings xr settings enable virtual reality supported and add these supported devices so oculus for oculus devices and open vr for open vr devices as you can see we also have another plugin in the list called mock hmd that we can add but what is this thing so as the name suggests this plugin is used to fake that we are currently having a net set plugged if it tells unity that even if we don't have any headset we still want it to do the computation for vr you know the rendering for each eyes and all of that good stuff and that comes really nd because it means that by using this you can still test the performance of your game without a vr headset now if you are using the old setup make sure to put the mock hmd plugin at the end of the list this way the game will still try to launch for oculus then for open vr and if it fails it will use by default the mock hmd now if you are using the new setup you basically have the same thing which is called unity mock hmd and that you can enable in the xr plugin management like the other plugin providers now that we have unity setup for vr let's try this so at this moment i don't have any headset plugged on my computer let's see if it still try to do the computation and here you go if i click on play as you can see on the game window i have a display for each eyes and i can even display both eyes at the same time oh and by the way i don't know if you already knew about this where this button you can select which eye you want to display on screen or even the occlusion meg okay now this was to fake a headset to test the performance of the game but how can we fake an input for example so let me show you i'm going to make an empty game object called hmd info manager and add a new component with the same name so hmd info manager now let's double click on the script to open it so my goal with this script is to get some information about if a headset is plugged or not to let us trigger any behavior that we want in that case and we can do this by actually writing at the top using unityengine.xr finally the information that we need are inside the xr settings as you can see with this class we can actually access the eye resolution the name of the device and some other interesting info like if a device is active or not now i just want to test these info so i'm just going to write in the console debug.log is device active plus xr settings that is device active and the same but for the loaded device name so debug.log device name is plus xr settings dot loaded device name and there you go now let's save our script and test our game okay so as you can see if i click on play we can see that the console is telling me that first we tried to vote for oculus but failed then we tried to load for openvr but failed again and finally we load the mock hmd sdk but as you can see it is telling me that the device active is true even if we have no headset plugged and that's because we are currently using the mock hmd plugin but if we go again to the player settings and that we remove the mock hmd which can be done in the same way in the new excel plugin management system by the way now if we click on play you can see that nothing is loaded and that active device is set to false so to sums up we can use this information to know if we have a loaded device or not so let's go back to our script and now to finally know if we have no device we can do if we have no device active it means that we have no headset plugged else if we have no device active but that the downloaded device name is mock hmd then it means that we have no asset plugged but that we are faking want to test our performance oh and by the way important note here the name mock hmd is the same used with the all vr setup but with the new setup it's a mock each indeed display so we need also to check that this name is not used to make this work for every setup so the old one and the new one and finally else we have a headset plugged that is using a device name that we can find with xr settings that loaded device name and there you go now basically with this you can trigger anything that you want in one of these case so the three uh case with uh it's a plug with no it's plug or by faking it with the mock hmd plugin which can be really useful for example to tell the user that your headset is not working with your game or for you to display some information on screen but most importantly to change the input of your game to be tested with a mouse and keyboard and not a vr controller for example and this is what i will show you now so when planning this tutorial i wanted to go over writing the code for this but in the meantime unity has launched the new version of its new unity xr toolkit and i have the good news to tell you that they have integrated in their new sdk a nixar player simulator that does exactly this job which is making you test the input of your game without a vr headset and this is what we will have a look at now so how can we set up the xr player simulator first thing first as usual we need to have an xric in our scene well to be able to use the controller and the headset all together now for this i'm going to right click in the rear key go to xr and click on room scale xr rig action base now i know that this might trigger some people because this is not what we used before in my tutorial series with the xr toolkit we use the device-based xlrig and not the action-based one which you can still find here by the way in device-based roon scale rig and don't worry this is just a version of the xrx that works with the new input system from unity and if you are interested in learning how this new input system works in vr let me know in the comment section below and i will cover it in a next video now when we create the action-based action rig as you can see we need to fill all the actions that we want for all the behavior of the rig now instead of creating them all unity has already pre-made some action that i'm going to use for this we need to go to the package manager select the xr interaction toolkit package that we have previously downloaded and in the additional package download the default input actions now that it is downloaded as you can see if we go to sample xr toolkit and then default input action we can see here all the default input unity as made for us so to enable them for our xr rig we can click on the default for the left controller and click here at the top on add action base controller default we can do the same for the right controller and finally now if we go to edit project settings preset manager we can now see that we have set these two presets and what's left for us to do is to say right in the filter for the right controller preset and left for the filter of the left controller preset now if we click back on the xrig as you can see the action have not been set yet but if we remove the actual xrig and that create a new one tada we have now or ixar rig ready with all the action set up correctly now a final step is required to activate this action and it's to add an input action manager somewhere in our scene so on the rig for example and drag there the x r a default input actions okay here you go now everything is ready you could test this and it would work in vr i'm sorry we had to go through this setup in this video but as some thing has changed in the meantime i thought that it was better so that everyone is on the same page now as you can see if i click on play as i have no vr headset the camera freeze and i am not able to do anything in my scene as before and this is why we will use the device simulator to control this xr big even without a vr headset so to set up the device simulator we need to go back to the package manager and if we select again xr toolkit we can see that we can download here the xr device simulator perfect and now from here that's really simple now that it is downloaded we can search in our project xr device simulator and drag the prefab in our scene so as you can see this component has a lot of parameter which are basically all the binding used to link a key from a keyboard to an action from the xrig so i don't know if if i double click on grip action for example you can see that this is linked with the g key on my keyboard in the input controller so we'll be able to fake that we grab an object by pressing the g key on the keyboard also we have some additional settings here with the speed of the movement of the control for example but instead of checking what key does what here let's try directly again to see how it works with the xr simulator ok now if i click on play so the first thing that we need to know is how to control here the camera so to control the camera we actually need to right click with the right click mouse and now as you can see i can move the camera left to right or up to down by moving the mouth now actually another control is to get closer or far from an object using the scroll wheel and as you can see it moved the camera accordingly now so as you can see we are able to modify the position of the camera when we grab it with the right mouse button but we can actually do exactly the same with the left hand or the right end so for this let me just leave play mode and i'm going to go under the left hand control and the right end controller right click go to 3d object cube so this will create a cube as a child of both the left hand and the right end so i'm going to select these two cube and scale them down to something a bit small like yes maybe this will work and maybe increase them on the forward axis now we can remove the box collider because we just want the visual and now if i click on play again so to take control of one of the hand it's not with the right mouse button that we do it for the camera but it's using the left caps button and now as you can see if i press it i can use it and move it in the same way as i did for the camera so by maintaining this button and moving my mouse as you can see it move left to right up or down and i can even get closer or far using the scroll wheel in the same way as the camera and we can do this basically for also the right hand so with instead this space button and as you can see i can do the same and there you go i can even control two object at the same time so for example i can have the camera here with the left hand or with the right end as you can see it follows or maybe i can grab the three all together and now as you can see all of the objects are moving and i can get far or close also we have also a control to a rotate and it's using uh the control button so as you can see if i press the control and the right mouse button i'm able to have a look at my scene from left to right and i can also do the same so if i take control with the caps lock for the left controller and that i press on the control button i can move and by the way you can also do this with the click on the mouse wheel so i can do exactly the same i can even tilt the object using both the click on the mouse wheel and the mouse wheel itself so i know that this needs a bit of coordination with the key but with a bit of training uh as you can see it will be a really easy but that is noted so we can move we can rotate and oh that's great but we can also interact with an object and so to show you this i'm going to simply create an easy intractable so first i will need a table for this so that i can put maybe over there i will create also another cube which will be a bit smaller and that i will put above this table we can set it to black i have here a black material in my scene that i've used to color the plane and i can drag it also on this cube that we want to interact with and so if i take this cue that i write a rigid body but also xrgrub interactable we should be able to grab this cube using the xr device simulator and i will show you how so if we now click on play okay so here you go i can still move and get the left controller as well as the right maybe we can uh get a little closer like this perfect and even move and so as you can see if i take control of the left end i can maybe rotate it also and pointing towards the interactable and as you can see it changed the ray to white and now if i press on the action key so the grab key as we saw before as you can see it grabs the object and i can even move it around like if i were grabbing it in vr and so basically that's it and if i release it for example as you can see i can place it on the table and basically that's it you have now seen how we can basically interact with an object and control both the camera but also the end using the xr device simulator now you can do you can do more than this you can actually trigger and activate object that you are using exactly in the same way that we would in vr but using other control that you can find here if you go under this component and you will be able to see what a key is doing what for the vrx so for example we have the trigger action if we double click on it the trigger action is triggered with the left bottom mouse and uh it's the same for all the things so we have the primary button which is b the secondary button which is n and uh it's the same for all of the other components so go take a look at this but you should be fine with just the simple control of moving and activating an object and this is how you can take control and test quickly your game without using a vr headset and there you go guys i hope that you enjoyed this tutorial which might be the first tutorial that i made without actually a vr headset from start to finish weird for vr tutorial i know as always thank you for watching till the end and if you'd like to support the channel make sure to like this video so that it will be recommended to other vr dev just like you a big big shout out to the new patreon join lately and if like them you want to help the channel and have access to exclusive content like the source code of all of my project and exclusive tutorial join us the link is in the description below anyway thank you for watching and see you in the next one
Info
Channel: Valem
Views: 41,720
Rating: undefined out of 5
Keywords: Unity XR Toolkit, VR Game without headset, XR Device Simulator, Unity VR Tutorial
Id: UlqdHrfXppo
Channel Id: undefined
Length: 18min 12sec (1092 seconds)
Published: Fri Dec 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.