Skip to main content
  1. Blog/

VR Beginnings

app VR
Phil Chu
Author
Phil Chu
Making software since the 80s

I’m a bit late to the VR party, still messing around with Cardboard. Even then, after an unsuccessful attempt to assemble a Cardboard viewer, I gave up on it until I found a couple of different non-cardboard Cardboard viewers at Toys ‘R Us.

So, finally, progress on the research phase. Tried out a few Cardboard apps (good timing, I’d just finished watching The Expanse and then saw the Expanse VR app advertised at CES).

Now, on to development. Thought about trying to make a VR version of HyperBowl, but decided to go with Fugu Maze, not just because it’s a much simpler app, but because it’s a simpler app, control-wise. The existing app just uses swipe-to-turn and press-to-move as controls.

Getting started involves downloading the Google Cardboard Unity SDK, reading their Getting Started documentation, and realizing they’re apparently just getting started on their documentation. In fact, the Getting Started section just tells you how to run the demo project.

The useful stuff is in the Samples and Tutorials section, in particular VR Stereo Camera Basics, which tells you to import the SDK into your Unity project, dragthe StereoController script under the camera. I did that in Fugu Maze, and immediately got stereovision!

It looks good in the viewer and automatically moves as you move your head. Look, Ma, no GUI! The tap-to-move button is not visible, which saves me the trouble of making it not visible (though I should really clean that up at some point), and the pause/options menu that initially appears I did deliberately disable. I gather uGUI elements do work with Cardboard, but have to be in world space to show up in stereo, so it was just easier for now to hide it. And I’m not sure I even want it for a VR version. Immersion, after all.

Motion is where I got bogged down. I want to use the magnetic trigger, the pull level on the viewer, to control motion. This script will detect the trigger:

void Start () {
 GvrViewer.Instance.OnTrigger += TriggerPulled;
 }
 
 void TriggerPulled() {
//
}

This API isn’t in the doc, so you have to figure this out by looking at the source code (or StackOverflow and then the source code). Also, by the way, I started working on this before Google repackaged their Cardboard SDK as GoogleVR and bundled it with the Daydream API. So I also had to look at the source code (and repo diffs) to figure out I had to replace Cardboard.SDK with GvrViewer.Instance. Migration doc would be handy, and, a nitpick, their link to the Unity SDK repo actually goes to the Android SDK repo.

Anyway, the trigger code works when simulated in the Editor, but the movement’s still not happening on the device although it’s definitely detecting the trigger. Close, but not cigar. Stay tuned on that. In the meantime, I’m going to start looking at getting a Rift-ready PC, when I graduate to deluxe VR.