Search Unity

Reticle/Crosshair

Discussion in 'AR/VR (XR) Discussion' started by Ibzy, Dec 15, 2015.

  1. Ibzy

    Ibzy

    Joined:
    Sep 15, 2013
    Posts:
    112
    I'm dabbling in VR using the Cardboard SDK and have a small issue with my crosshair that I hope somebody could help with.
    I have 2 canvases (one on the left camera, one on the right) each with a dot rendered in the center. The majority of the time it looks fine, but if i get too close to an object it causes my eyes to go funny. It is like the dot is being rendered further away than the object I'm looking at, but is still visible, and thus causes some optical illusion.

    Has anybody else experienced and/or fixed this? Alternate suggestions to my current set up are also welcome.

    Thanks
     
  2. Daniel-mayles

    Daniel-mayles

    Joined:
    Oct 30, 2015
    Posts:
    3
    Yeah sadly this is due to your eyes adjusting to the depth. The fix I used for this is placing the cross hair at the same depth as your scene objects. Here is the code I use to do this.

    Code (CSharp):
    1.  
    2. RaycastHit hit;
    3. float distance;
    4. //When a collider is hit set the distance to the distance of the collider else set the distance to be far away
    5. if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, maxCastDistance, CrossHairTargetLayers))
    6. {
    7.       distance = hit.distance;
    8. }
    9. else
    10. {
    11.       distance = camera.farClipPlane * 0.95f;
    12.  }
    13. //Set the new cross hair position based on the distance
    14.         transform.position = camera.transform.position + (camera.transform.forward * distance);
    15.         transform.LookAt(camera.transform.position);
    16.         transform.Rotate(0.0f, 180.0f, 0.0f, Space.Self);
    17.    
    18. //Scale the cross hair so it's the same size even when it's in the distance.
    19.         transform.localScale = originalScale * distance;
    20.  

    This video also explains the problem and how to fix it better than I did as well :)
     
    Ibzy likes this.
  3. Ibzy

    Ibzy

    Joined:
    Sep 15, 2013
    Posts:
    112
    Amazing. Thanks so much for your response! :)

    Do you have a clip of how it looks in your project?
     
  4. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    General rule don't render anything within 1 meter of your face for a long period of time (yes this is hard). Within one meter your brain uses the angle of your eyes to calculate distance. This wont match with what is actually going on as your eyes are looking at a screen, thus the signals will conflict and you will feel uncomfortable.
     
    augustcero likes this.