jorgegarciax2
jorgegarciax2

Reputation: 67

How to get gaze/cursor coordinates in Hololens?

I'm trying to get the gaze coordinates from the Hololens. The main idea is get the intersection between my look ray and the Hololens mesh.

Upvotes: 1

Views: 3113

Answers (2)

Kevin Moroney
Kevin Moroney

Reputation: 31

Your scene should have a mainCamera object which represents the position of the headset, getting the transform on this object should give you what you are looking for. The snippet below should do it for you.

Camera.mainCamera.gameObject.transform.position

You can check the Unity documentation for cameras here :

https://docs.unity3d.com/ScriptReference/Camera.html

Also check out GazeManager from the Mixed reality toolkit.

https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/master/Assets/HoloToolkit/Input/Scripts/Gaze/GazeManager.cs

Upvotes: 1

Dtb49
Dtb49

Reputation: 1271

All you would need to do is get a reference to the Cursor Game Object and then get its position. That will get you the coordinates for where you are looking at.

public GameObject Cursor;

Vector3 gazePos = Cursor.transform.position;

Upvotes: 1

Related Questions