Search Unity

Strange issue with raycasting from the camera center in Daydream?

Discussion in 'Daydream' started by stregillus, Jan 2, 2017.

  1. stregillus

    stregillus

    Joined:
    Oct 9, 2016
    Posts:
    10
    I have a control in my game that requires me to see if a ray is going from the "center" of the view into the control and into the object behind it. I've been doing this with this code:

    Code (CSharp):
    1. //in Start
    2. _pointerData = new PointerEventData(EventSystem.current);
    3. _pointerData.position = new Vector2(0.5f * Screen.width, 0.5f * _raycastResults = new List<RaycastResult>();
    4.  
    5. //this function is called from Update:
    6. public void CastRaysFromVision()
    7.     {
    8.         if (EventSystem.current != null)
    9.             EventSystem.current.RaycastAll(_pointerData, _raycastResults);
    10.  
    11.         _overSliderPane = false;
    12.         _overSlider = false;
    13.         foreach (RaycastResult result in _raycastResults)
    14.         {
    15.             if (result.gameObject == this.gameObject)
    16.             {
    17.                 _overSlider = true;
    18.             }
    19.             else if (result.gameObject == sliderPane)
    20.             {
    21.                 _overSliderPane = true;
    22.                 _positionOnPane = result.worldPosition;
    23.             }
    24.         }
    25.     }
    This actually works fine if the viewer is configured to be a Cardboard headset in the Daydream app, or from a normal non-Daydream phone with just the Cardboard app.

    However, if I am using the Daydream headset, the raycast seems off, and I have to look slightly above where the object is. It also feels like I am slightly smaller when I have the Daydream headset active. Any ideas on why?
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
  3. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
  4. stregillus

    stregillus

    Joined:
    Oct 9, 2016
    Posts:
    10
    The eye texture width was the issue! Thank you.
     
    Selzier likes this.