- Home /
How to reset Time.time ?
Please help.. My scenario is display CustomerA(prefab) which have a timer script in object, after i click a CustomerA, it's will destroy and display againt CustomerA in random time and timer countdown againt from beginning..
I already create a script called CustomerTimer.cs which attached to CustomerA to make countdown timer in it
CustomerTimer.cs
private void Update ()
{
if(!stopTime)
{
countDownTime();
}
}
private void countDownTime()
{
timesRemaining = startingCountDownTimer - Time.time;
percent = timesRemaining / startingCountDownTimer * 100;//calculate percent
setSprite(percent);//if percent is 0 then object will be destroy automaticly
}
Object will be destroy if i click on an object and object will be appear again in random time.
For example if starting count down from 45 second and object destroy at second 20 (timesRemaining = 45-20 = 15) then after object respawn again a new game object timesRemaining will be start from 15 because Time.time is not reset from 1 again
Can i reset a Time.time but in one game object only ? I know the problem but i don't know how to solve it..
Sorry for my bad English.. Thanks
Answer by dhanrajsinh24 · Jun 13, 2014 at 08:55 AM
Time.time is read only and it can not be resetted. You have to use System.time.timer class of C# for your calcualtions.
Your answer
Follow this Question
Related Questions
Stop and Resume Timer 0 Answers
Changing light intensity over time via mathf.lerp 2 Answers
Time based scoring 2 Answers
Why Won't This Message Log Into My Console? 1 Answer
Format String Minutes:Seconds 3 Answers