Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
hash280689's avatar
hash280689
Honored Guest
11 years ago

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:


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
Replies have been turned off for this discussion