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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
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