How to get gaze input position in unity5 using GVr?

I am following a tutorial where when the mouse moves over,a cross grid appears.

if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),out hit,25.0f)

This is what is used in the script. How can I modify this so that I get the position of the GVr reticle instead?

I need to know the position of the Gvr gaze(ie,reticle). Any help is appreciated.

Upvotes: 0

Views: 1122

Answers (1)

Umair M
Umair M

Reputation: 10720

I never worked with GVR but from my experience with Ocullus VR I assume that reticle / gaze is always looking at center of view so you can use camera position to get start point for your raycast. Like this will give you world point:

// use your main camera
Vector3 p = camera.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, camera.nearClipPlane));

Remember view port is (0,0) at bottom left and (1,1) at top right. So you will need (0.5f,0.5f) for center of view port and z component of input Vector3 is nearClipPlane of your camera. Hope it helps

Upvotes: 1

Related Questions