x


Countdown little help...!

Hi... I have this little script countdown timer.

var myTimer : float = 5.0;

function Update () {
 if(myTimer > 0){
  myTimer -= Time.deltaTime;
 }
 if(myTimer <= 0){
  Debug.Log("GAME OVER");
  Application.LoadLevel (1);
 }
}

I want also to show that countdown time on the top right corner of my screen. How can i do that? Just edit the script and show me how. Thank you.

more ▼

asked Nov 22 '10 at 11:19 AM

tomeromero gravatar image

tomeromero
75 15 15 22

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
var myTimer : float = 5.0;

function Update () {
 if(myTimer > 0){
  myTimer -= Time.deltaTime;
 }
 if(myTimer <= 0){
  Debug.Log("GAME OVER");
  Application.LoadLevel (1);
 }
}

function OnGUI(){
 GUI.Label( Rect(Screen.width - 200, 0, 200, 30), "Time: " + myTimer );

}
more ▼

answered Nov 22 '10 at 11:36 AM

denewbie gravatar image

denewbie
717 3 3 17

hah u beat me to it, and even in JS :) Nice work

Nov 22 '10 at 11:41 AM Proclyon

Thanks^^. JS is tough for me cause I converted to C# half a year ago. The my backend engines are in java... These days I'm just confused with all the syntax...

Nov 22 '10 at 11:44 AM denewbie

Hey guys, I used this script too - btw, thanks for it. but how can I change fonts on the timer?

Apr 21 '11 at 06:59 PM simpleone
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1865
x570
x491
x470
x76

asked: Nov 22 '10 at 11:19 AM

Seen: 1184 times

Last Updated: Nov 22 '10 at 11:19 AM