So I am having a problem trying to get World coordinates to Screen Coordinates. I have the function, but when ever I attempt it the GUI labels always end up WAY off the target GameObject. Here is my OnGui:
var posVector = Camera.main.WorldToScreenPoint(transform.position);
var labelRect : Rect;
labelRect.x = posVector.x;
labelRect.y = posVector.y;
labelRect.width = 50;
labelRect.height = 20;
GUI.Label(labelRect,lifeLeft.ToString());
Kinda confused. BTW my camera is on orthogonal if that makes a difference
Thanks
EDIT:
var posVector = Camera.main.WorldToScreenPoint(transform.position);
var vectorTwo : Vector2 = GUIUtility.ScreenToGUIPoint(new Vector2(posVector.x,posVector.y));
var labelRect : Rect;
labelRect.x = vectorTwo.x;
labelRect.y = vectorTwo.y;
labelRect.width = 20;
labelRect.height = 20;
GUI.Label(labelRect,lifeLeft.ToString());