- Home /
Isometric Game Labels Not Displaying Correctly
Hey I'm making an isometric game that has customers buying food and preforming different actions. I would like a little speech bubble or image to appear next to them depending on what they are thinking or feeling. The problem is that the camera is set to orthographic so the GUI.Label isn't tracking the position of each customer correctly. It's hard for me to explain so look at the picture. :)
Notice how the labels are sticking to the top of the screen.
static var currentWaypointMirror: int;
var agent: NavMeshAgent;
var script1: SlideOutMenu;
var activeWaypoints: Transform[];
var inactiveWaypoints: Transform[];
var masterWaypoints: Transform[];
var startMoving = false;
var selectedMenuItem: int;
var subtractedBurgers: int;
var subtractedGlucks: int;
var subtractedBopsters: int;
var customerID: int;
var chairSet: int;
var labelPos : Vector2;
var labelSize : Vector2;
var customerPos : Vector2;
var cameraer : Camera;
function Awake() {
customerPos = transform.position;
customerID++;
agent = gameObject.GetComponent. < NavMeshAgent > ();
agent.speed = Random.Range(2.5, 5);
script1 = gameObject.Find("GUIElements").GetComponent(SlideOutMenu);
}
function OnGUI(){
GUI.Label(Rect(labelPos.x, labelPos.y, labelSize.x, labelSize.y), "Customer");
}
function Update() {
var labelStuff : Vector3 = cameraer.WorldToScreenPoint(Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z));
labelPos.x = labelStuff.x - labelStuff.y;
if(script1.activateWaypointSet[1] == false && script1.activateWaypointSet[5] == false){
WaitForUpgrades();
}
ScanForSets();
CheckActiveWaypoints();
TurnOnEntity();
if (startMoving == true) {
waypoint = activeWaypoints[currentWaypoint];
agent.SetDestination(waypoint.position);
}
}
Answer by Jeff-Kesselman · Jun 23, 2014 at 11:00 PM
You need to project the world position back to a screen position to draw on.
You can do this using http://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html
I did that but then I get an effect where the label will follow the customer but will start to move perpendicular to the customer. Does that make sense?
Your answer
Follow this Question
Related Questions
How to keep track of multiple GUI Windows? 2 Answers
OnGUI called after LateUpdate screwing up debug text database 1 Answer
GUI.Label font size scale - using GUISkin 1 Answer
show entered amount gui/label 2 Answers
positioning gui! 2 Answers