Gadgetory


All Cool Mind-blowing Gadgets You Love in One Place

How to Create a VR App for Android in 7 Minutes

2018-06-21
it might not have caught on in the massive way that everyone's been anticipating it will do just yet but VR is still definitely going to play a huge role in the future of tech and the future of Android VR has almost limitless potential to change the world whether that means influencing the way we create communicate learn or game and as our mobile devices get more powerful and computer vision allows for true inside out tracking much of this is like to take place on our Android phones but for now we have Google cardboard and daydream and the gear VR they're a little less exciting the new oculus rift and HTC vibes sure but there's still some pretty awesome games and applications here and there are lots of great reasons for developers to get involved not only because there's lots of money to be made in their fledgling VR app stores but also because it pays to get ahead of the curve and learn skills that are likely to be in huge demand in the next few years and apart from anything else it's just incredibly awesome to be able to create your own virtual world and then step into it so that further ado let's see if we can make those eighties dreams a reality and try to make our own VR experience on Android in just seven minutes or less so the first thing we need to do of course is to open up unity there is we're going to start a new project even though I've done this once before is a trial we'll call it VR app make sure that you've got 3d selected and then click create project pretty easy okay and here we have unity if you're not familiar with using unity then there are plenty of articles and tutorials over at Android Authority calm that I've written and others have written and I'll link to those in the description also okay so the first thing we want to do I'm going to kind of rush through it here for now the first thing you want to do is to create a 3d plane that just means a flat surface and the reason we want that is so that we can walk on it and I'm going to make this a little bit larger we've got plenty of room to move around okay we can also insert a 3d object which is a cube here just to add a little bit of variety to our world if we wanted to give that physics without a rigidbody now we want to make this a 3d first-person shooter type experience so we're going to go down to assets here and we're gonna say import package characters this is going to allow us to import various ready-made assets you can of course select just the things you want from the standard assets here but for now for simplicity let's just import everything and give it a moment hold on okay so now that's created what we're gonna do is look in the standard assets here we're going to go to characters we're gonna go to first person we're going to prefabs a prefab as a ready-made a game object it could have scripts it could have 3d models or prefabricated hence the name ready for us to use this is a completely ready first person character controller and as you'll see it makes our lives incredibly simple so just drop it into your scene from there we want to delete the main camera here because the first person controller is now going to act as the camera and now if you click play you'll see just how quick and simple everything was ago we can look around there's that box we can walk around with the Mazda keys we can jump this sound effects all that's been added by that first-person controller pretty nice and easy believe it or not that's ready for us to jump into so the next thing we need to do first we're gonna save our scene we could make a folder for that if we wanted to keep things nice and neat but for now let's just call it simi a scene in unity is not to just the level it also includes all the elements that you've included so that means things like this first person character controller okay so now with that saved we're ready to set this up to run so we're gonna go to build settings want to change our platform to Android so select that and click switch platform to make it official once again you need to give it a couple of seconds we need to hold on okay and the next thing we need to do once that's done is to move our scene into the scenes in build that's important because without that there it's not going to know what to include when it creates our app now finally click player settings and this is where you set up the settings for your app itself the first thing we need to do is in other settings that's cool company name Android or authority and that's called the product name VR app with no space then I'm going to change my package name and you need immunity to be very strict and make sure that that is the company name and then the app name we also need to make sure we're targeting API level 19 because it's only from there upwards that we can support Google cardboard so that's done then we're going to go into X our settings and just click virtual reality supported that's the magic sauce right there you can see here you've got the opportunity to import virtual reality SDKs we're going to click the plus there and we're going to choose cardboard but of course if you wanted to daydream you just click daydream and if you wanted oculus you just click oculus note however that oculus is a little bit more complicated because you're also going to need a signature file from your device but for these two it's incredibly simple so just click cardboard and then you can click build and run and your project is complete and ready to test on your device which is pretty amazing really then you can load it up look around and explore your 3d world of course for this to work you need to have your Android device plugged in and you need to turn on USB debugging if you can't find that setting then it'll be in the developer options in your settings menu if you don't have access to developer options you'll need to turn that on you do this by going to about phone finding the build number and then tapping on that seven times it'll then say you're now a developer you can change those hidden settings now of course this is all good and well and pretty amazing really we don't yet have any way to interact with the world we can change this however by clicking FPS controller finding the first person controller script that's the code that handles this behavior going to that two settings menu the little cog on the right clicking on it and then saying edit script that less edit the code now the good news is that Google cardboard only has a one input method that being the magnetic button at the top and that's pretty easy for us to override so in here do a search and look for jump and there you go we've got this line as long we want em underscore jump equals cross-platform input manager get button down jump we're gonna change that to input get mouse button down zero and all that's doing is it's swapping the kind of adaptable jump button for a mouse click and the good news is that Android immunity interprets a mouse click as being the same thing as tapping the screen anywhere and that also happens to be the same way that Google cardboard interprets a click of that button so this means that now clicking the button will make our character jump but you could just as easily make that a button to make the character move forwards to make it fire so you can shoot a target and that's where you can start to use your imagination and come up with really cool ideas for new VR apps like I say we're really only at the start of this technology right now there's so much potential that hasn't been explored giving you the opportunity to come up with that really killer app that awesome idea that no one's had before the only thing holding you back really is the limits of your imagination and if you want some ideas and some more tips on how to create more immersive VR experiences then once again there's an article I've written over Android Java comm and I'll link to that once again in the description down below so we found this video useful interesting guys if you did then please leave like please share it around that helps us out immensely let me know in the comments down below if you have any problems I'll try and help you out and what you'd like to see in this tutorial next time of course check out Android or 30 com if we are your source for all things Android
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.