Five months ago I decided to start using Unity for the first time and I figured that doing a small VR Roller Coaster would be a nice little project to start with. In no time I had a proper VR Roller Coaster prototype working all fine and dandy so I moved on to other things that needed my attention but I always wanted to share how I managed to do it and maybe someone else would find it useful for themselves or even somebody else could create a better project built on it. So, hope you like it and here’s how I did it:
Setting up a New VR Project in Unity
Before starting I highly recommend you watch Ryan Zehm’s tutorial on How To Build A Mobile VR Game with Unity, it was his easy to follow videos that got me started. And while you’re at it also check this inspiring story about how he went from homeless to at-home game development.
- Open up Unity and click New at the top, give a name to your project and choose a location for it.
Click Create Project and Unity will create a folder with your project’s name on your chosen location.
- Download Google VR SDK for Unity. Back on Unity go to Assets>Import Package>Custom Package… and import the package you have just downloaded;
- Next you wanna go the Hierarchy panel, right click your Main Camera and select Delete from the drop down menu. You’ll be using the stereoscopic Cardboard camera that comes with the imported package.
On the Project tab, go trough Assets>Cardboard>Prefabs and then drag and drop CardboardMain into your scene.
On the right side, in the Inspector panel, reposition the asset with the following coordinates: X0,Y2,Z0;
- Now it’s probably best to have some type of terrain so you can look around and actually see something. I’ve made a simple low poly vulcano island in blender and exported it as a .fbx file. Unity can import .blend files just fine but if you plan on using Unity’s Cloud Build latter on, .blend files are not supported yet. So go ahead and create your own terrain or feel free to Download the one I made and import it through Assets>Import New Assets… and reposition it at the center;
- Because I’m an Illustrator and I like pretty things I also want a nice cloudy sky around my scene. In the asset store tab search for Fantasy Skybox FREE and you’ll find an awesome free package. For this tutorial you will only need to import the material Sunny 01B.mat and the 6 corresponding textures that make up the skybox;
- Once you have imported the skybox go to the Hierarchy panel, select your Main Camera (CardboardMain>Head>Main Camera).
In the Inspector panel choose Skybox from the Clear Flags dropdown.
Next to the Inspector panel, go to Lightning>Scene and choose Sunny 01B.mat for the Skybox. For the Ambient Color choose #A0B4B4FF, tick the Fog option and for the Fog Color choose #5CB3E1FF;
- Now lets create a light so we can have our scene properly lit. In the top menu go to GameObject>Light and click Directional Light. In the Inspector panel choose #FFFFDCFF as the color for the light;
- Back in the Hierarchy panel click the Water object to select it. Now, in the Inspector panel choose a different Shader for the Water, from the dropdown menu choose Unlit>Color. And for the color, type in #5CB3E1FF or just use the eyedropper to select the skybox’s bottom color. Also, if you want to get rid of all those unrealistic reflections on the island just go through all the materials and drop the Smoothness to 0;
- Now lets test what you have done so far, at the top hit Play. Look around your scene holding down the Alt key while you move your mouse cursor;
- If everything is working fine, then it’s time to run your project on your own device. In my case I’m using an Android mobile, so if that’s your case too, in the top menu select File>Buid Setting…, choose Android as your platform and then click Switch Platform. Once everything is loaded, click Player Settings, go to the Inspector panel and choose Landscape Left as your Default Orientation. Connect your phone via usb cable, make sure you have debug mode turned on and press Build And Run.
Part 2 is here. Thanks!