- Home /
Why is my timer reseting itself?
So, I have some code for a hunger system.
#pragma strict
var Hunger:float;
var MaxHunger:float=1000;
var timer:float;
function Start ()
{
Hunger=MaxHunger;
}
function Update ()
{
timer+=Time.deltaTime;
if(timer>=10)
{
Hunger-=0.20;
}
}
The only problem is that once the timer reaches 10, it resets itself. This is going to be a problem because later I'll be using the same timer for other things. Does anyone know how to keep the timer from resetting, but still subtracting 0.2 from Hunger every second AFTER 10 seconds?
Can you post more code? Specifically the code that resets the timer, because this code does no timer resetting. Also, what do you mean by reuse the same timer? This script seems very non-generic and specifically geared toward ti$$anonymous$$g hunger. Do you just mean you want to get a good algorithm down before copy/pasting the timer elsewhere?
Your answer
Follow this Question
Related Questions
How to Reset Score and Variable Problem? 1 Answer
Resetting Timer Using PlayerPrefs? (JS) 1 Answer
how to make a varied countdown timer 1 Answer
How to make a variable decrease every five seconds? 3 Answers
variable reset not working. 0 Answers