- Home /
Question by
$$anonymous$$ · Jun 17, 2015 at 07:08 PM ·
javascriptguiguitextureworldtoscreenpoint
WorldToScreenPoint returns the same value when facing the opposite direction.
I have a GUITexture I am placing over the top of an objective to show its position but the problem is it also shows
the when facing the opposite direction. I have found that the WorldToScreenPoint function is returning the same
value when facing the opposite direction, am I doing something wrong or is there a way to fix this? Thanks in
advance c:
#pragma strict
public var map : GameObject;
var mainCamera: Camera;
var mapScreenPos : Vector3;
var GUIObject : GUITexture;
function Start() {
//mainCamera = GetComponent.<Camera>();
}
function Update() {
mapScreenPos = mainCamera.WorldToScreenPoint(map.transform.position);
GUIObject.pixelInset.x = mapScreenPos.x - (Screen.width / 2) -25;
GUIObject.pixelInset.y = mapScreenPos.y - Screen.height / 2;
Debug.Log("target is " + mapScreenPos.x + " pixels from the left");
}
Comment