Setting up a Simple Gaze Interaction

Tyler Smallwood
3 min readJan 25, 2024

--

Objective: Use Gaze Interaction to find the Key Lock

In more advance VR headsets, such as the HTC Vive Pro Eye, Varjo Aero, Varjo VR-3, and Varjo XR-3. But with the Quest 2, the one I am using, does not but that doesn’t matter with the Gaze interactor. For non-eye tracking headsets, the Gaze Interactor will have the RayCast from from the center of the eye’s or forehead.

To be able to use the Gaze function we will need to add another component under our XR Origin.

On here, we will add the XR Gaze Interactor, XR Controller (Action-based), and Gaze Input Manager. The Gaze Input Manager will determine if the headset has eye tracking or not.

Only thing we need to do for these three components is to add input actions to the XR Controller. This is to track Eye position, Rotation, and State.

And that’s all. To have an example of it working, I created a little puzzle. You need to be wearing a hat while looking at the mirror to have the keylock appear.

To do this, we will add a XR Simple Interactor to the Mirror. Create and set a Interaction Layer mask to Gaze. So only the Gaze will work and not the Raycast interactor. Set the Gze Configuration to Allow Gaze Interactor. Next is to drop the KeyLock game object into Hover and set it to enable. To make sure you are wearing the hat for it to work, we will disable the XR Simple Interactable component.

On our Hat Socket we will enable that game object but dropping the mirror into the Select event section and enable the component. We’ll also make it if you take the hat off, it’ll disable the component again.

And with that everything is ready.

Thanks for reading!

--

--

Tyler Smallwood
Tyler Smallwood

Written by Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

No responses yet