Search Issue Tracker

By Design

Votes

19

Found in

2017.3.0a1

2018.2.0a1

2018.2.11f1

2018.3.0a1

2019.1.0a1

Issue ID

1100140

Regression

No

[XR][OpenVR] ScreenPointToRay() is offset when used in VR

XR SDK

-

Steps to reproduce:
1. Download and open the attached project
2. Enter playmode in VR
3. Set aspect ratio to "Remote" if not done automatically
4. Position HMD to look at any of the sphere objects
5. Focus Game view and move the mouse on any of them

Expected result: a raycast is registered and the sphere dissapears
Actual result: the raycast does not hit exactly where the objects are, but in the area around them

Reproduced on 2017.4.15f1, 2018.2.16f1, 2018.3.0b10, 2019.1.0a9

Notes:
- Only reproducible on OpenVR SDK, not on Oculus SDK

  1. Resolution Note:

    The root of the problem is that what you see in the gameview window if cropped : it's only 70% of the whole image (only for SteamVR).
    With this knowledge, you can easily adjust your code to fix the issue :

    var screenPos = Vector3.zero;
    screenPos.x = 0.15f * camera.pixelWidth + 0.7f * Input.mousePosition.x;
    screenPos.y = 0.15f * camera.pixelHeight + 0.7f * Input.mousePosition.y;

    Ray ray = camera.ScreenPointToRay(screenPos, camera.stereoActiveEye);

Comments (3)

  1. dhami-nitin

    Jun 17, 2022 12:36

    still facing same issue but with Nreal

  2. spockthegray-mk2

    Jan 25, 2021 23:38

    Hi, is this an issue still in Unity 2020?

  3. mattabaker

    Jul 07, 2020 19:38

    This solution does not work in free aspect ratio.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.