- Home /
Question by
Lukekul · Feb 16, 2012 at 03:40 PM ·
checkpoints
GUI Label not drawing on screen
I'm Trying to get a label to display text that changes when the player crosses checkpoints in a tutorial level, but it's not showing up. Any ideas what I've done wrong here?
Tutorial Manager Script:
public var checkpoints : Transform[];
private var temp : boolean;
private var temp2 : Transform;
private var cPointed : int = 0;
private var say : String;
function Update () {
for(i = 0; i <= checkpoints.Length; i++){
temp2 = checkpoints[i];
temp = temp2.transform.GetComponent("Checkpoint").returnCrossed();
if(temp == true){
cPointed++;
}
}
passed(cPointed);
OnGUI();
}
function passed(passed : int){
if(passed == 1){
say = "Use the Right Analog Stick to Move the Camera";
}
if(passed == 2){
}
if(passed == 3){
}
if (passed== 0){
say = "Use the Left Analog Stick to Move";
}
}
function OnGUI(){
GUI.Label(Rect(Screen.width-Screen.width, Screen.height - Screen.height/5, Screen.width /2.5f, Screen.height/5), say );
}
And the Checkpoint Script:
private var crossed: boolean;
private var player : Transform;
function Awake(){
player = GameObject.FindWithTag("Player").transform;
crossed = false;
}
function OnTriggerEnter (other : Collider) {
if(other.tag == "Player"){
crossed = true;
}
}
function Update () {
}
function returnCrossed(){
return crossed;
}
Comment
Your answer
Follow this Question
Related Questions
Endless runner distance calculation problem 2 Answers
How can i save an entire scene when a checkpoint is hit 1 Answer
Individual racers passing checkpoints racing game unity 0 Answers
Check my race code please 3 Answers
Reset function for AI car? 0 Answers