Interactive Gaze Detection
with VR & Unity
Dr James Birt
Requirements
• Unity 5.3 or higher
• Oculus runtime 0.8 installed
• Introductory VR in Unity 3d
Gaze Detection
• Detecting where the user is looking is very
important in VR
• This allows a user to interact with an object,
trigger an animation etc
• Currently VR is limited – without eye tracking to
accurately determine a users gaze
• We therefore need to estimate the user’s gaze
• This is typically determined by a mid point
between the users two eyes (or the centre of
the camera)
• In a program like Unity we would cast a ray
forward from this centre point and find what
the ray has collided with
The Reticle
• Gains the name from a
sighting device such as a
telescopic lens
• Can help to indicate the
center of the user’s
vision
• The style of the reticle
could be a simple dot,
or perhaps a crosshair
4
Interactive Reticle
• Follow my Introductory VR in Unity 3d tutorial
• OR final package can be downloaded here
• Remember to set your build settings and quality
settings as highlighted in tutorial
• Import the Reticle package - this has been
modified from the Unity3d Interaction in VR
sample scenes - http://tinyurl.com/z9cc8w8
5
Creating a Reticle Camera
6
• Add MainCamera Prefab as a child to
FPSController
• Copy the Transform details from
FirstPersonCharacter to MainCamera
• Delete FirstPersonCharacter
• Switch off Return to Main Menu Script
on MainCamera – Error will occur
Test the Reticle by adding multiple objects to your
scene
7
• Notice that your Reticle
scales correctly to your
objects
• Appears correctly in front
and on top of the objects in
your scene
Interactive Objects
• Try dragging an Interactive
Object into the scene from the
Prefab folder
• You will notice the VR
Interactive Item & Example
Interactive Item Script(s)
attached see what happens
when you Gaze over this
object
8
9
VRInteractiveItem.cs
10
Sets Boolean conditions if these Action events take place
and calls the corresponding function
ExampleInteractiveItem.cs
11
Here we are handling the outcome
of the Events – You can do whatever
you want in these functions the
script(s) just needs to be placed on
a gameObject
Testing multiple objects and events
12
• When adding a new interactive gameObject
make sure to include the VR Interactive Item
Script and Example Interactive Item Script
• You need to add the Object to the Interactive
Item and Renderer
• Notice we can have multiple instances of the
objects and scripts and we know which object
is being triggered at any time
Final
Scene
https://dl.dropboxusercontent.com/u/9011716/VRRETICLEDEMO.unitypackage

Gaze detection with Virtual Reality and Unity 3d

  • 1.
    Interactive Gaze Detection withVR & Unity Dr James Birt
  • 2.
    Requirements • Unity 5.3or higher • Oculus runtime 0.8 installed • Introductory VR in Unity 3d
  • 3.
    Gaze Detection • Detectingwhere the user is looking is very important in VR • This allows a user to interact with an object, trigger an animation etc • Currently VR is limited – without eye tracking to accurately determine a users gaze • We therefore need to estimate the user’s gaze • This is typically determined by a mid point between the users two eyes (or the centre of the camera) • In a program like Unity we would cast a ray forward from this centre point and find what the ray has collided with
  • 4.
    The Reticle • Gainsthe name from a sighting device such as a telescopic lens • Can help to indicate the center of the user’s vision • The style of the reticle could be a simple dot, or perhaps a crosshair 4
  • 5.
    Interactive Reticle • Followmy Introductory VR in Unity 3d tutorial • OR final package can be downloaded here • Remember to set your build settings and quality settings as highlighted in tutorial • Import the Reticle package - this has been modified from the Unity3d Interaction in VR sample scenes - http://tinyurl.com/z9cc8w8 5
  • 6.
    Creating a ReticleCamera 6 • Add MainCamera Prefab as a child to FPSController • Copy the Transform details from FirstPersonCharacter to MainCamera • Delete FirstPersonCharacter • Switch off Return to Main Menu Script on MainCamera – Error will occur
  • 7.
    Test the Reticleby adding multiple objects to your scene 7 • Notice that your Reticle scales correctly to your objects • Appears correctly in front and on top of the objects in your scene
  • 8.
    Interactive Objects • Trydragging an Interactive Object into the scene from the Prefab folder • You will notice the VR Interactive Item & Example Interactive Item Script(s) attached see what happens when you Gaze over this object 8
  • 9.
  • 10.
    VRInteractiveItem.cs 10 Sets Boolean conditionsif these Action events take place and calls the corresponding function
  • 11.
    ExampleInteractiveItem.cs 11 Here we arehandling the outcome of the Events – You can do whatever you want in these functions the script(s) just needs to be placed on a gameObject
  • 12.
    Testing multiple objectsand events 12 • When adding a new interactive gameObject make sure to include the VR Interactive Item Script and Example Interactive Item Script • You need to add the Object to the Interactive Item and Renderer • Notice we can have multiple instances of the objects and scripts and we know which object is being triggered at any time
  • 13.