Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Finding VR Eye Position (including lens distance offset) - holographic sight

Discussion in 'AR/VR (XR) Discussion' started by wirelessdreamer, Mar 20, 2017.

  1. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    134
    I'm working on build a holographic sight, I need to be able to know the exact location of the players eyes to do the math on it properly. I found a reference to: UnityEngine.VR.InputTracking.GetLocalPosition(VRNode.RightEye) but when I draw it for testing, the line does not originate from my head.

    Debug.DrawLine(UnityEngine.VR.InputTracking.GetLocalPosition(VRNode.RightEye), zeroLocation, Color.green);

    What object can I use to get the location of the left and right eyes, seperately, and accurately.

    Thanks
     
  2. OutOfRam

    OutOfRam

    Joined:
    Mar 12, 2015
    Posts:
    3
    I realize this is a year late and you probably have since either solved the issue or given up, but in the interest of helping out those who may need this in the future(and because I my self just spent the better part of a week trying to figure this out). The answer is actually not that complicated:

    Make sure first that you have the following up with your using statments:

    using Valve.VR;


    then in your code simply use:

    OpenVR.System.GetEyeToHeadTransform(EVREye.Eye_Right).m3;

    This will give you the position of the right eyes camera relative to the headset. for the left eye simply change EVREye.Eye_Right to EVREye.Eye_Left. from there you can subtract the two to get total distance, or you can use the headsets position + eye position to get the eyes real world position etc...

    I hope this helps!