Setting up a Simple Gaze Interaction!
Objective: Understanding how to create Gaze Interactions.
What are Gaze Interactors? Gaze Interactors are interactions based on where the player is looking. If you are using a headset that doesn’t use eye tracking, then the Gaze will come out of the middle of your headset.
To set up a Gaze Interaction first we need to create an empty object child to the main camera, which is under our XR Origin. On this empty object we can start by adding the Gaze Interactor component.
To keep our Interactors from intercepting it is best practice to create a new Interaction Layer Mask specifically for the gaze interactors in your environment.
For a gaze interactor to work it needs an XR Controller (Action Based) component. Now, unlike when we created the controllers for our hands, for this we do not need to enable any inputs actions. However, we do need to enable input tracking.
The XRI Default Actions do give up references for the position, rotation, is tracked, and tracking state action. So, select each reference and select the eye action.
The final component we need to add to this gaze interactor object is a script that has been provided by unity in the sample pack. The script is named GazeInputManager. This script will automatically determine when the gaze is being used.
For this tutorial I have also added the components XR Interactor Line Visual and Line Renderer. You won’t need this, but for this tutorial it will show the gaze interactor in action.
Moving on, we can now move to the object in your scene that you want to interact with the Gaze Interactor. With that object selected you need to add two components. A collider, as well as an XR Simple Interactor.
Remember, we need to keep this on the same Interaction Layer Mask as our Interactor. Under the Gaze Configuration we will need to enable Gaze Interaction.
Now you are all set. Technically you have completed setting up your Gaze Interactor. What do you do from here? Well, that depends on what you are using the interactor for. For an example, let’s say you are wanting to have an object appear after you look at your Gaze Interactor.
Under the Interactable Events you can add an event to the First Hover Enter. I’ve selected the lock we used in a previous tutorial and have disabled the object in the scene. I want this gaze interactor to enable it. This way the player will never see the lock, unless the look in the mirror.
Remember, your Gaze Interactor won’t have that ray shooting from it. That is all there is to it. Don’t be afraid to experiment with your Gaze Interactors and I’ll see you in the next tutorial!