Google Cardboard, with more than 5 million users, is a success for Google. So, it’s not a big surprise when Google announced their next step into the world of virtual reality with the evolution of Google Cardboard: the Google Daydream, a more robust and enhanced mobile VR platform.
So, what is Google Daydream? Is it just a better version of Google Cardboard? How does it differ from Google Cardboard?
Well, they are both platforms for mobile VR apps that can be viewed in a mobile headset. Unlike Cardboard though, Google Daydream has a set of specifications that mobile devices and headsets must follow. This means developers would know exactly what kind of input the user of their apps would have, something that wasn’t possible on the Cardboard platform.
The biggest and the most notable feature of Google Daydram compared with Cardboard however, is the addition of a motion-based controller. Users will now be able to use this remote-like controller to point and interact with the virtual world much more intuitively. With this controller, developers would be able to build a better and more immersive VR experience.
As can be seen in the image above, there are 4 physical inputs available to the user on the Daydream Controller:
- Touchpad (the big circular pad)
- App Button (the button with the line symbol)
- Home button (the button with the circle symbol)
- Volume buttons (the buttons on the side)
And since it’s a motion-based controller, the controller comes with various sensors to detect the user’s hand movement. Do note that the movement that can be detected by the controller is mostly limited to rotational movement, unlike the fully positional tracked controller on a PC VR platform.
Two more things to keep in mind: the first one is that the home and volume buttons are not accessible to developers and are reserved for the platform’s functionality. The second one is that the touchpad is only capable of detecting single touch. And since the documentation doesn’t mention multitouch being added in the future, it’s safe to assume that the controller is designed for single touch and will stay that way for the foreseeable future.
All right, now that we know about what the controller can do, let’s dive deeper into the Google Daydream SDK and figure out how to use the Daydream Controller in our apps.
Before we go further though, let’s make sure we have all the requirements for developing Daydream apps:
- Unity 5.6 (with native Daydream support)
- Google VR SDK for Unity v1.2
- Daydream Controller or an Android phone with Gyroscope.
Yes, you don’t have to own the controller to develop a controller-compatible app, so don’t fret. Instead. we’re going to emulate the daydream controller using an Android phone. To do that, all we need to do is to install the controller emulator APK on our phone and run the emulator app. Then, to enable the emulator to be detected on Unity Editor, we simply connect the phone to the computer with a USB cable.
Do note that we can’t connect the actual Daydream Controller to our computer and will only be able to use the controller when it’s paired to a mobile phone. So you may want to use the emulator for testing purposes even if you have the controller.
To start reading user input from the controller, we first must add the GvrControllerMain prefab to our scene. Afterwards, we can simply use the GvrController API to detect any user interaction with the device. The GvrController API behaves similarly to Unity’s Input API, so you’re in luck if you’re familiar with the Unity project.
Like the Unity Input API, there are three functions to use if we want to find out the state of the buttons on the controller. Use the GvrController.ClickButtonDown property to check if the touchpad was just clicked, the GvrController.ClickButtonUp property to check if the touchpad was just released, and the GvrController.ClickButton property to see if the user is holding down the touchpad click. Simply replace the “ClickButton” part with “AppButton” to detect the state of the app button on the controller.
The API for the controller’s touchpad is similar to the Unity Mouse Input API as well. First, we need to find out if the touchpad is being used by calling the GvrController.IsTouching property. Then, we can read the touch position with GvrController.TouchPos property. There is no function for detecting swipes and other movements, but you should be able to create your own detector by reading the touch position changes.
For traditional controllers, these properties should be enough to get all the user inputs. However, Daydream Controller is a controller for VR, so there’s still another aspect we should read: Movement. Using the GvrController.Orientation property, we can get a rotational value of the controller’s orientation in the real world. We can then apply that value to a GameObject in our scene and have it mirror the movement of the controller.
And that’s it for our introduction to the Daydream Controller. The world of virtual reality is still vast and unexplored, and every day, new ways to interact with the VR world are being tried out.So, keep experimenting!
About the author
Raka Mahesa is a game developer at Chocoarts who is interested in digital technology in general. Outside of work hours, he likes to work on his own projects, with Corridoom VR being his latest released game. Raka also regularly tweets as @legacy99.