How Do I Make A 3D Text Count Down?
What do you want to count? What have you tried so far? Are you having difficulty with a particular part of the scripting interface? If you’re not going to put any thought into problems before you ask questions, at least put some thought into the questions themselves. Ambiguous questions are much less likely to get you helpful responses.
I need to COUNT down in NUMBERS so I can make a TIME bomb.
Patronizing people isn’t going to get you very far, either.
The formula for time remaining before a given time is:
timeRemaining = givenTime - currentTime;
So your script might look like this:
var detonationTime = 10.0;
function Update() {
GetComponent(TextMesh).text = detonationTime - Time.time;
}
“MissingFieldExeption: Cannot find variable text.”
Looks like because it’s a String you need to use this:
GetComponent(TextMesh).text = "" + (detonationTime - Time.time);
Almost! It works according to real time. If I don’t set a bomb for two minutes then it will be 120 seconds below zero!
You’ll have to set the detonation time whenever you make a bomb.