Search code examples
c#unity-game-enginehololens

Maintaining eye contact with GameObject on Hololens 2 with Unity


I need to create a c# script for unity that checks if the player is maintaining eye contat with a GameObject (the check function is called in the Update() function)

However when I tried to do this it didn't work, at best it was fine when i watched in the general direction of the object but it didn't consider the height of the object.

Side Note, the object is always 1.5 units above the camera, but it can be moved and so can the player (don't know if this infos can help).

Sadly I don't have any code since I tried to do this some days ago and deleted the scripts. I'm using Hololens 2020.3.34 and MRTK 2.8.


Solution

  • Just resolved this, used the function EyeTrackingTarget on the object that needed it, after implementing the Eye Gaze Provider from the MRTK Toolkit.

    More info at this link: https://learn.microsoft.com/en-us/windows/mixed-reality/mrtk-unity/mrtk2/features/input/eye-tracking/eye-tracking-target-selection?view=mrtkunity-2022-05