Forum Discussion
hash280689
12 years agoHonored Guest
Trouble with World-to-screen point on Oculus 0.4.3.1
Hi
I am trying to use make it so that I have a marker on the GUI which shows me the location and distance of another object relative to me. I have managed to get this working with a normal camera.
When I try and use this with the Oculus Camera however, the y-values are completely off. If I get further from the object, the marker's y-coordinate increases rather than staying the same relative area.
Here is the GUI code:
I'm using Unity 4.5.5p3 and Oculus SDK 0.4.3.1
I am also using the VRGUI package which basically just converts normal unity GUIs into an Oculus GUI mesh. It's been working for me so far, except for now.
Thanks
I am trying to use make it so that I have a marker on the GUI which shows me the location and distance of another object relative to me. I have managed to get this working with a normal camera.
When I try and use this with the Oculus Camera however, the y-values are completely off. If I get further from the object, the marker's y-coordinate increases rather than staying the same relative area.
Here is the GUI code:
Vector3 itemToScreenPosition;
float distanceToTarget;
void Update()
{
itemToScreenPosition = rightCamera.WorldToScreenPoint(targetTransform.position);
distanceToTarget = Vector3.Distance(targetTransform.position, rightCamera.transform.position);
}
void OnVRGUI()
{
textureDimension = new Vector2(Screen.width / 10, Screen.height / 10);
float posX = itemToScreenPosition.x;
float posY = Screen.height - itemToScreenPosition.y;
GUI.DrawTexture(new Rect(posX, posY,
textureDim.x, textureDim.y),
locatorTexture);
}
I'm using Unity 4.5.5p3 and Oculus SDK 0.4.3.1
I am also using the VRGUI package which basically just converts normal unity GUIs into an Oculus GUI mesh. It's been working for me so far, except for now.
Thanks
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago