Search Issue Tracker
Fixed in 2018.2.X
Votes
3
Found in
2017.1.0f3
Issue ID
940733
Regression
No
ScreenPointToRay has a huge offset when using VR headset
Steps to reproduce:
1. Open attached project "940733.zip"
2. Open "Sample" scene
3. Select 'Main Camera' in the Hierarchy
4. Under 'TestRaycast' script component set 'TestMode' to ScreenCenter
this will cast a ray to the center of the screen and place the 'sphere cursor' there
5. Connect VR device and enable VR Support
6. Enter Play mode
Result: ScreenPointToRay(center of the screen) returns a direction with a huge offset
Alternatively:
1. Under 'TestRaycast' script component set 'TestMode' to MouseInput
2. Enter Play mode
3. Hold mouse button 0 and move the cursor around the screen
Result: ScreenPointToRay(mouse position) returns a direction with an offset depending on the mouse position (video attached)
Reproducible with: 5.6.3f1, 2017.1.0p3, 2017.2.0b6, 2017.3.0a3
Devices used:
HoloLens - only reproducible with Holographic Emulation in Editor, but not in builds
Oculus Rift DK2 - reproducible in builds as well as in Editor
Note: ScreenPointToRay works just fine without VR support
Comments (3)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- After converting a Built-in project to URP render texture related errors are spammed that can lead to Game view being rendered on top of Scene view
- UI Builder slider value lags and stutters when sliding/modifying certain property values
- "Reset UI Builder Layout" functionality inconsistently changes Canva Size when "Match Game View" is enabled/disabled
- Texture Import Warnings are obscured by other Terrain Layer options in the Inspector
- Burst Inspector middle divider is jittering when resized with the Burst Inspector window docked
Max_Aigner
Apr 19, 2022 14:42
sorry for pushing this super old topic. Anyway for someone having stumbling above this post now, the solution was fairly simple:
Just change the "Target Eye" for your "Camera" to "None (Main Display)" and everything will work again.
Also the UI.
Max_Aigner
Apr 19, 2022 13:50
Well I do have the same issues here in Unity 2020.3.23f1
If I disable the VR Support, the ScreenpointToRay command workes like a charm. But as soon as I turn on Oculus Quest 2, the Origin of the ray is off. The direction however works fine. (Oculus Quest 2 connected to the Computer via the Oculus cable)
vbs
Dec 06, 2017 02:51
I have tried both
Ray ray = cam.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
and
Ray ray = new Ray(m_Camera.position, m_Camera.forward);
as well as visualizing the rays with
Debug.DrawRay(ray.origin, ray.direction * m_DebugRayLength, Color.green, m_DebugRayDuration);
and
Debug.DrawRay(m_Camera.position, m_Camera.forward * m_DebugRayLength, Color.yellow, m_DebugRayDuration);
and for me the direction of the ray is good, but the origin is never the center of the camera / viewport on the Y axis. the Y axis seems to be 0, even though my camera is clearly not at 0 on the y axis. (rays shoot from the feet of my character in VR, using Oculus Rift. Unity 2017.3.f10