Friday, December 16, 2016

Google Cardboard Input

Successfully setting up input for Google Cardboard has a lot to do with applying scripts to the right place.  This post will cover what I've found to be the minimal set to get this working.

Please follow the setup steps in this Post as a prerequisite, as you'll need to have loaded the SDK package into your project, and added a GvrMain to your scene.

Setup the Scene

  1. On the GvrMain
    • Add the GvrPointerManager script
  2. On the Main Camera under the GvrMain
    1. Add the GvrPointerPhysicRaycaster script
    2. Add a GvrReticlePointer prefab as a child of the Main Camera
  3. Add an EventSystem to the scene
    1. Remove the StandaloneInputModule script
    2. Add the GvrPointerInputModule


Add an Object to Gaze Upon

  1. Add a Collider component to your object (not Is Trigger)
  2. Add an EventTrigger script (will populate later)
At this point when you run the game, you should see the reticle in the viewer (both eyes), and when that reticle lands on your object, it should expand into a circle.  If this occurs, then you did everything correctly.


Respond to Gaze Events

  • Create a script that has functions that perform your desired actions for the gaze events, (i.e. on enter, on exit, on click, etc).

  • Add events to your event trigger (on the object with the Event Trigger)
    • Associate the events to functions in the script in step 1.

Now when you enter/exit or click when gazed at the object, your function actions should execute.


Having successfully completed it, I would recommend that you save the scene/project as a template which can be used later (or make a bunch of prefabs).

No comments:

Post a Comment