Setting up a Simple Gaze Interaction

Have the Key Hole Appear Only when the Player Wears a Hat & looks into the Mirror

Jordan T Kay
3 min readMay 7, 2024

To enhance the escape room, it is time to introduce a new type of interactor and a new type of interactable…

GAZE INTERACTOR COMPONENT

This type of interactor is used for interacting with interactables via a raycast that is updated based on a few conditions.

  • If the player is intended to be wearing an advanced headset that supports eye tracking (Apple Vision Pro, Meta Quest Pro, VIVE Pro) then the raycast is updated via the player’s eye movement
  • By default if the player’s hardware of choice does not support eye tracking, then the raycast is updated via the player’s headset as the raycast origin is set to the center of the player’s head (in between the eyes)

Gaze interactors will only interact with Simple Interactables and Grab Interactables that have Allow Gaze Interaction enabled.

SIMPLE INTERACTABLE COMPONENT

Similar to the Grab Interactable, the Simple Interactable turns an object into an interactable object that can respond to interaction events with no underlying interaction behavior, thus allowing an object to respond to gaze interactions without allowing it to be grabbed.

The plan to enhance the escape room has two phases…

PHASE 1

OBJECTIVE: Mirror’s Simple Interactable Component should be enabled when player is wearing a hat and disabled when player isn’t wearing one

STEP ONE — MIRROR GAMEOBJECT

The following components need to be added to the Mirror GameObject

Box Collider [Trigger Enabled]
XR Simple Interactable [Allow Gaze Interact Enabled] [Component disabled by default]

STEP TWO — HAT SOCKET

To have the XR Simple Interactable enabled/disabled based on if the player is wearing a hat, we need to adjust the interactor event on the Hat Socket, having the XRSimpleInteractable enabled on Select Entered and having the XRSimpleInteractable disabled on Select Exited.

TEST 1

Now when the player wears a hat, the Simple Interactable will be enabled (allowing us to configure an event to be executed via gaze interaction). But when the player is not wearing a hat, the Simple Interactable will be disabled, effectively disabling all gaze interaction events on the mirror.

PHASE 2

OBJECTIVE: Have the Key Hole appear when the player gazes into the mirror

Now we need to configure the XR Simple Interactable Component on the mirror to enable the Key Hole GameObject on the Hover Interactable Event.

To give the player the power of interacting with the virtual world through their eyes, we must also create a Gaze Interactor on the XROrigin.

NOTE: To have the Hover Interactor Event only execute on the hover of the Gaze Interactor, the Simple Interactable AND the Gaze Interactor needs to only be active on the Gaze Interaction Layer Mask. Also the Ray and Direct Interactor should NOT be on the Gaze layer.

TEST 2

--

--

Jordan T Kay

Join my journey into game development with Unity. Learning all I can to produce quality games. 🚀