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:
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.
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:
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:
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:
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:
And now we’ll have a fresh new Unity project:
Now we need to re-import everything we exported.
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:
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:
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.
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:
To actual technical problems:
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!