Any idea to create simple countdown (10,9,7… seconds) when I enter some collider?
- When countdown is 0, something happens.
- When I leave collider (OnTriggerExit) nothing happens, but If enter again, countdown will begin from 10s again.
I tried to play with Time class, but with no succes.
Thx
Do you mean the time countdown code?
In penelope project, ScoreKeeper.js
There is a function which could help you
public function TimeRemaining() : String
{
var remaining : int = timeLeft;
var val : String;
if(remaining > 59) // Insert # of minutes
val+= remaining / 60 + ".";
if(remaining >= 0) // Add # of seconds
{
var seconds : String = (remaining % 60).ToString();
if(seconds.length < 2)
val += "0" + seconds; // insert leading 0
else
val += seconds;
}
return val;
}
Wow, that was realy fast answer! Thank you, it should be exactly what I need…
Ok, It almost working… Time down counter is ok, but I need to disappear the countdown, when leave the Collider (OnTriggerExit).
If I set timerGui.text = “”; it disappers for 1 second, but then appear again and continue with countdown…
I used all “needed” functions from this Penelope JS script file…
If I set to my OnTriggerExit function:
guiText.enabled = false;
and in other Trigger functions “true”, countdown doen’t show…