Table of Contents

Gaze Interaction

Unity's XR Interaction Toolkit offers a Gaze Interaction system that allows users to interact with objects in VR using their eye gaze through XRGazeInteractor. This component handles gaze-based interaction. It casts a ray forward based on the user's eye pose (or head pose if eye tracking isn't available) and detects interactable objects.

The Ray interaction consists of:

  • Gaze Interactor: XRGazeInteractor is the interactor used for interacting with Interactables via gaze. This is handled via ray casts that update the current set of valid targets for this interactor. This component is provided by Unity´s XR Interaction Toolkit. VIROO provides an already configured Gaze Interactor for the player.
  • Simple Interactable: XRSimpleInteractable is the component with which XRGazeInteractor interacts.
  • Viroo XR Simple Interactable: this component is in charge of configuring the way XRSimpleInteractable interacts with the interactors and also that the interaction events are triggered to all users in session through the network.
Important

Gaze Interaction at runtime is disabled by default, to enable it, you must open the VIROO menu and activate it. The Gaze Interactor will run at the same time as other interactors.

Add a Gaze Interaction to a GameObject

To add a Gaze Interactor to an object you must:

  1. Set up the interactable object with the necessary components.
  2. Configure the events you want to handle.

Set up the Gaze Interactable object

This interactor will interacts with XR Simple Interactable that have enabled Allow Gaze Interaction.

  • XRSimpleInteractable: Unity´s XR Interaction Toolkit component.
  • Collider: this GameObject or its children must have one or more colliders.
  • NetworkObject: necessary to identify the GameObject by VIROO Networking.
  • VirooXRSimpleInteractable: necessary to setup how XRSimpleInteractable is interacted and to launch the events through the network.

XRSimpleInteractable

This is a Unity´s XR Interaction Toolkit component and is the simplest version of an Interactable object. It is intended to be used as a way to respond to interaction events with no underlying interaction behavior. For more information please refer to the official documentation here.

Collider

For Gaze Interactor to interact with Simple Interactable, it is necessary that there is at least one collider, which can be at the same level of the component or in one of its children. The collider can NOT be of type Trigger.

NetworkObject

For network functions to work properly, interacting components need this component that uniquely identifies them across the network. It is therefore important to ensure that their ObjectId identifier is not repeated.

VirooXRSimpleInteractable

This VIROO component is necessary to setup how XRSimpleInteractable is interacted and to launch the events through the Network.

The XRSimpleInteractable component by default does not differentiate if it is being interacted by a Direct Interactor, Ray Interactor or a Gaze Interactor. That is why VIROO, through this component, provides a way to limit the way in which it interacts with this interactable in order to configure it so that it can only be interacted by an interactor of one type and not by both.

Field Description
Send Network Events If this box is checked the events triggered by the XRSimpleInteractable (HoverEnter, Activate...) will be networked, otherwise the events will be triggered only locally.
Allow Direct Interaction If this checkbox is checked it means that the associated interactable will interact with a Direct Interactor.
Interact With Hands In this field you can specify whether the interactable is hand-interactable. It has four possible values, None, Left, Right, Both. Allow Direct Interaction must be checked.
Tag Filters If you want the interactable to interact only with specific DirectInteractors, you can define tags for this purpose. For more information check the Custom Direct Interactors section in this page. Allow Direct Interaction must be checked.
Allow Ray Interaction If this checkbox is checked it means that the associated interactable will interact with a Ray Interactor and Gaze Interactor.
Allow Distance Select Interactor Check this checkbox to allow interactable be selected remotely through a Ray Interactor instead of having to use a Direct Interactor. It is commonly used to be able to grab objects from a distance.

The configuration when we want to have a Gaze Interaction is to have Allow Direct Interaction disabled and Allow Ray Interaction enabled.

viroo-simple-interactable-ray-interaction.png

If you want to configure the interactable so that it can only be interacted with by the Gaze Interactor, you can specify this by setting the layer that the interactable interacts with by putting it on the Gaze layer.

simple-interactable-gaze-layer.png

Configuring the Events

At this point you can use XRSimpleInteractable events to trigger logic when the Gaze Interaction happens. VIROO Interaction System ensures that XRSimpleInteractable events are propagated over the network to all users if Send Network Events is selected. With this, the events you subscribe will be called to all users in the VIROO Application.

If you want to use the VIROO Interaction System Actions and you are sending events through the network, you must use the LocalExecute functions (instead of Execute).

Here are the most common events that are used when performing Gaze Interaction.

Event Description
Hover Entered The event that is called when an Interactor begins hovering over this Interactable.
Hover Exited The event that is called when an Interactor ends hovering over this Interactable.

A complete list of all events is available here