This Unity project demonstrates the basic setup for eye tracking using a Meta Quest Pro headset.
The project utilizes a GameObject named CenterEyeAnchor
located under OVRCameraRig/TrackingSpace
, which represents the center between both eyes.
The individual eyes are represented by the GameObjects LeftEyeAnchor
and RightEyeAnchor
.
The OVREyeGaze
script attached to each of these rotates and moves the GameObject in the space.
Among other things, the Confidence Threshold
can be set here, which is necessary to determine the required confidence level for applying the detected change in the eyes to the object.
The CameraRay
script, attached to the CenterEyeAnchor
utilizes the position and rotation of the LeftEyeAnchor
and RightEyeAnchor
to calculate an average of the position and rotation of both eyes and use that to create a raycast.
For debugging purposes, a visible line can be drawn by setting the drawDebugLine
variable.
Objects of the Highlighter
class have their IsHovered
variable set to true
when looked at, allowing them to apply a different material accordingly.
This is where other behaviors can be implemented, or interactions with other classes can be added in the CameraRay
script when looking at these objects.
- Open the Unity project and then navigate to the
SampleScene
within it. - Navigate to the
OVRCameraRig
in the hierarchy and locate theLeftEyeAnchor
,CenterEyeAnchor
andRightEyeAnchor
GameObject. - Adjust the
Confidence Threshold
parameter in theOVREyeGaze
scripts attached to theLeftEyeAnchor
andRightEyeAnchor
GameObjects if necessary. - Ensure you have the Meta Quest Pro headset connected and properly set up. (Check the connection in the Oculus app, and verify if the device is listed in Unity under File -> Build Settings -> Run Device.)
- Make sure that Android is selected as the platform in the build settings (File -> Build Settings -> Android -> Switch Platform). Run the Unity scene (File -> Build and Run).
- Look at the objects in the scene to trigger highlighting and see the eye tracking in action.
- Use this project to use eye tracking with Unity and Meta Quest Pro in your own project.
- For more complex interactions, consider extending the functionality of the
Highlighter
class or integrating interactions with other scripts when objects are being looked at. - Ensure proper calibration and positioning of the Meta Quest Pro headset for accurate eye tracking results.