Jump to content

Need help getting the location the player is looking


Recommended Posts

Hi, 

Fairly new to all of this VR tracking, in short I want to know where the using is looking, and also what object they are looking at and printing this out to the debug console. 

 

Thank you in advance 🙂

Link to comment
Share on other sites

Look at the API for GetGazeRay
Here is one entry for that:
 

static bool  GetGazeRay (GazeIndex gazeIndex, out Vector3 origin, out Vector3 direction, EyeData_v2 eye_data)

 

What it does is gives you the direction the eyes are looking in the vector "direction".

If you want to know what the object is looking at you can take the direction vector, and the origin of the vector and use RayCast to see if the gaze ray is hitting any colliders. Or, it will be easier to use the focus method:
 

static bool  Focus (GazeIndex index, out Ray ray, out FocusInfo focusInfo, float radius, float maxDistance, int focusableLayer, EyeData_v2 eye_data)

 

which will tell you if any colliders are being looked at, and tells you the nearest collider that they gaze hits. focusInfo will contain all of the information about what is being looked at. @Kodiak @Corvus

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...