Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Today, we’re finally going to work in VR! We're going to try and convert our simple FPS into a VR experience that we run from our phone!
Welcome back to Day 36! Yesterday we set up our mobile device to be able to play VR device and there’s nothing quite like that experience, especially if you’re the one that “made it”.
If you’ve made it this far in the journey, but you haven’t tried using the Cardboard or other VR devices, I highly recommend trying it once!
Now… with my pitch out of the way, let’s talk about what we’re going to do today!
We're finally started working in VR, today, we’re going to try and convert our simple FPS into a VR experience.
This will be a multi-day progress. Today, I want to:
Do some Asset clean ups for our app so we don’t have to spend forever building
Set up our Google VR tools
Play our game
Before we get started. I realize that not everyone (or anyone) followed me step by step to get to Day 36.
In our Simple FPS game, we have reached a complete prototype so I’ve decided to make a Github Repository of our game before we start adding the VR components in. Specifically, after doing some manual cleanup work in Step 1.
Now anyone can start following along to build our VR application.
You can find my Simple VR First Person Shooter GitHub repository here.
If you haven’t tried switching to the Android platform in our simple FPS game, you might notice, that it… takes… FOREVER.
I’ve tried building the app (and I waited 10+ minutes). Thank goodness for the Unity previewer, I would not know what to do if I had to build my app on my phone every single time!
Luckily, I found that Google/Unity does have a solution for this. Google has Instant Preview. Unfortunately, which loads the game into our phone while also playing on the editor. The bad news is that this only appears to be for the Daydream Viewer so I’m going to hold off for now.
However, let’s see what we can do to optimize this!
When I say optimize, I really mean get rid of our un-used assets! Looking at what we have, we have 1 GB worth of files! That’s not good!
Unfortunately, this didn’t exactly work. I tried to export all our dependencies and then import it into a new project and there were some problems.
It turns out, things like Layers and Tags do not get preserved so if we wanted everything to work, we had to manually add everything back in.
Instead, I used the files I exported into a new project as a reference and then manually removed assets from a copy of our project (that’s what I get for not having source control!)
Also from testing with a before and after build time, I believe that un-used assets DO NOT improve our build and runtime, so the only useful thing that came out of Step 1 was that I:
Cleared some clutter so we can find files more easily now
Made the project smaller so people can download it from Github faster, so not a complete loss!
Let’s get rid of our old un-used files! How? Well, a quick search on how to get rid of unused assets in Unity.
All we need to do is:
Select our scenes, which in this case is just Main
Right-click and click: “Select Dependencies”
Export our assets by going to Assets > Export Package… and save your package somewhere.
Warning: This will not export Editor scripts and plugins, which in our current situation, is not a problem.
Now at this point, we have 2 choices:
Delete everything and re-import the assets that we exported or…
Create a new project and import our exported project
I’m going to do the 2nd choice and make a new project.
We’re going to create a new project and import everything we just exported. To do that:
Select File > New Project…
Call your file whatever you want, but I’m going to call mine First Person Shooter VR
And now we’ll have a fresh new Unity project:
Now we need to re-import everything we exported.
Go to Assets > Import Package > Custom Package and find the .unitypackage that we just created
Afterwards, just choose to re-import everything
The next thing we need to do after we have our new project is that we need to import the Google VR SDK and configure our Unity.
I’m going to be lazy and just refer us to Day 35: Setting Up Google Cardboard In Unity.
Just do the exact same thing in downloading the SDK and setting up our Unity configuration.
Note: In the repo, I already included Google VR SDK 1.100.1 and the necessary changes for Player Settings. I assume the PlayerSettings are project-based and not computer-based, but if it’s not, follow the instructions in Day 35.
At this point, we should be almost ready to play our game!
At this point, we have:
imported the Google VR SDK
Switched to the Android platform
configured our PlayerSettings to the appropriate settings to run a Google Cardboard app
The last thing we need to do that’s specific to our Game Project is that we try to build in Build Settings… we run into a problem to resolve incompatibilities between Color Space and the current settings.
To fix this, we just need to change our Color Space from Linear to Gamma. To do that:
Go to File > Build Settings > Player Settings > Other Settings > Color Spaces
Change Linear to Gamma
With this setting in, we’re ready to build our game.
To do that, I recommend running the development build to build our app.
Contrary to what the name sounds, development build DOES NOT make our build faster, instead it allows us to have access to useful debugging settings gives us access to the Profiler and Script Debugging.
Now once you’re ready, let’s build our game! Make sure your phone is connected to your computer.
Go to File > Build Settings…
Enable Development Build
Click Build And Run
You can save the APK anywhere.
Now enjoy the long wait~!
That’s it for today!
Today we cleaned up a bit of our project and then set up the game so that we can run our app directly from our phone.
The build is long and horrendous, which is unfortunate. There are a couple of solutions available, but I’m going to look at them some other day.
We can also play the game directly from Unity. If we were to play the game right now, we’ll encounter problems.
From a technical limitation:
We can’t move
We can’t reload anymore
To actual technical problems:
The enemies are all black color
We don’t have any of our UI’s anymore
I’ll have to investigate these things and solve them one at a time, but I can finally say, we’re here! We’re finally working in VR!
That’s what we’re going to try and tackle the next couple of days. It’s going to be a fun one!
Read more about:
BlogsYou May Also Like