- Home /
Question by
jho_2212 · Mar 13, 2014 at 04:32 PM ·
countdown3dtextgui-problem
3dText problem
i want to put timer . but the sad thing my guitext is not working when i put guitext i dont have see anything text. i try 3d text and i saw the text "hello world" . but my problem is the code. can i use this code to 3d text?
var guiCountDown : GUIText;
var countMax : int;
private var countDown : int;
function Start(){
guiCountDown.enabled = true;
GameStart();
}
function GameStart(){
var car= gameObject.Find("Car");
var drivingScript = car.GetComponent("Car");
drivingScript.enabled=false;
for (countDown = countMax; countDown>-1;countDown--){
if(countDown == 0){
guiCountDown.text = "GO!";
}
else
guiCountDown.text = countDown.ToString();
yield WaitForSeconds(1);
}
guiCountDown.enabled=false;
drivingScript.enabled=true;
}
thanks :)
Comment
Answer by jacobschellenberg · Mar 13, 2014 at 06:29 PM
You'll want to use the Text Mesh.
I've modified the script a little, but it works perfectly. I also included a sample package.
In the scene is: Camera, Car, TextMesh
#pragma strict
var guiCountDown : TextMesh;
var countMax : int;
private var countDown : int;
function Start(){
guiCountDown.active = true;
GameStart();
}
function GameStart(){
var car = gameObject.Find("Car");
var drivingScript = car.GetComponent("Car");
drivingScript.active = false;
for(countDown = countMax; countDown >= 0; countDown--){
Debug.Log("Count: " + countDown);
if(countDown == 0){
guiCountDown.text = "GO!";
}
else{
guiCountDown.text = countDown.ToString();
}
yield WaitForSeconds(1);
}
guiCountDown.active = false;
drivingScript.active = true;
}
Your answer
Follow this Question
Related Questions
Timer not work :( 0 Answers
Timer Countdown problem 2 Answers
CountDown Camera problem 0 Answers
BCE0044: expecting ), found ';'. 1 Answer
Making a countdown out of 3D planes. 1 Answer