Daydream offers motion controller support for Unity and Unreal. These features include:
Controller visualization: A 3D model of the Daydream controller that displays which button the user is currently pressing and where the user is currently touching the Daydream controller's touchpad.
Laser and reticle visualization: Displays a laser and reticle so the user can easily interact with the VR environment.
Arm model: A mathematical model to make the 3D controller model in VR approximate the physical location of the Daydream controller.
Input System: A standard and extensible framework for raycasting from the controller model. The input system integrates with the laser and reticle visualization to make it easy to interact with the UI and other objects in VR.
All visualization elements are optional and reskinnable.
Controller support in Unity
Daydream controller support in Unity is available through prefabs included with the GVR SDK for Unity.
The steps below detail how to create a simple VR Unity app that demonstrates the 3D controller model, laser and reticle, and tooltips.
- Download and install Unity 5.6 or newer.
- Download the Google VR SDK for Unity.
- Create a new 3D Unity Project.
- Configure the build settings to enable Daydream support.
- Import the GVR SDK for Unity.
- Under the Assets menu, select Import Package, then Custom Package, then navigate to the Unity GVR SDK and select it.
- Enable support for the Daydream controller and UI.
- Create an empty GameObject and name it Player.
- Set the position of the Player object to (0,1.6,0).
- Place the Main Camera underneath the Player object at (0,0,0).
GvrControllerPointerunderneath the Player object at (0,0,0).
- Set the position of the Main Camera to be (0,0,0).
GvrEditorEmulatorto the scene, located under GoogleVR/Prefabs.
GvrControllerMainto the scene, located under GoogleVR/Prefabs/Controller.
GvrEventSystemto the scene, located under GoogleVR/Prefabs/UI.
- Save the scene.
- Open File > Build Settings. Add the current scene to the scene list and make sure it's the first scene enabled.
- Press Build & Run to run the example.
Daydream provides a 3D model of the Daydream controller that displays which
button the user is currently pressing and where the user is currently touching
the Daydream controller's touchpad. The controller model is managed by the
GvrControllerVisual.cs script. To access this script, add the
GvrControllerPointer prefab to your scene, available under
GoogleVR/Prefabs/UI, and click the triangle icon to view all the nested prefabs.
The script is attached to
GvrControllerVisual.cs exposes a number of properties that let you customize
the look and feel of the controller visualization.
Daydream provides a set of customizable tooltips for the Daydream controller model.
The tooltips are controlled by four objects nested under the
Tooltips prefab, available as
The four tooltip prefabs correspond to their locations relative to the controller and the given handedness settings. You can change the handedness setting by pressing the Change Handedness button in the Gvr Tooltip script component.
By default, the tooltips will only appear when the user is looking closely at the controller.
The Tooltip script also lets you customize the location, text, and context as to when the tooltips appear.
Laser and reticle visualization
GvrLaserPointer script, available on the Laser prefab nested under
controls the laser visualization. The laser lets users locate their cursor when it's
not directly in their field of view. The
GvrLaserPointer script has the following settings:
- Laser Color: Determines the color of the laser.
- Max Laser Distance: When you're not currently pointing at an object, this is the maximum distance in meters that the laser will render.
- Max Reticle Distance: When you're not currently pointing at an object, this is the maximum distance in meters that the laser reticle will render.
Daydream provides an arm model, a mathematical model that uses the orientation and location of the physical controller, and predicts the location of the shoulder, elbow, wrist, and pointer to determine where to place the controller model within the scene.
The arm model is controlled through the
GvrArmModel script, which is attached
to the provided prefab
GvrArmModel script allows you to adjust the following properties:
- Added Elbow Height: Adds an offset to the predicted elbow height.
- Added Elbow Depth: Adds an offset to the predicted elbow depth.
- Pointer Tilt Angle: Downward tilt of the laser pointer relative to the controller in degrees. The default value of 15° is optimized for ergonomic comfort when interacting with objects at eye level. If the user needs to interact with objects significantly higher or lower than they are, you may need to adjust this property.
- Fade Distance From Face: Controller distance from face after which the alpha value decreases.
- Follow Gaze: Determines if the shoulder should follow the user's gaze.
Use Accelerometer: Turning the accelerator off makes the controller feel more precise and predictable. Turning it on reduces precision but can make the user feel more like they're holding a real object.
Daydream provides an extension of
Unity's event system
that optimizes working with the Daydream controller. To make use of this system,
GvrEventSystem prefab to your scene. You can configure the Input
System through the
attached to this prefab.