Hey guys,
I wrote this script to draw a box around targets on my screen:
var spaceObj : Transform;
var targetTexture : Texture;
var cam : Camera;
private var screenPos : Vector3;
function applyBox () {
screenPos = cam.camera.WorldToScreenPoint (spaceObj.position);
if (spaceObj.renderer.isVisible) {
GUI.DrawTexture(Rect(screenPos.x, screenPos.y, 50, 50), targetTexture, ScaleMode.ScaleToFit, true, 0);
}
}
function OnGUI () {
applyBox();
}
It gives me no errors but it simply doesn’t work correctly: the box is not in the right position (the x axis looks ok, the y one is messed up: it goes above or below the target depending on my up&down movements). I think it’s a camera-related problem… I’m currenly using a third-person camera with smooth follow script attached…
How can I fix it?
Thanks in advance