- Home /
drop health every fifth second
Hey, I would like to know how to drop your health down every fifth second.
I've figured out that it's in the update I must fix the script, but how?
Comment
Best Answer
Answer by Nonakesh · Sep 06, 2011 at 12:09 PM
Maybe there is a better solution but try this:
private var timeDifference = 0.0;
function Update () {
timeDifference += Time.deltaTime;
if(timeDifference >= 5) {
timeDifference = 0;
DropHealth();
}
}
for correct answer. :) Note you could also use coroutines and yield new WaitForSeconds(5.0) for this.
Answer by Novrick · Sep 06, 2011 at 12:17 PM
forgot to mention it is C sharp I'm working in, I'm a beginner so I don't know if it was c sharp you answered in
Your answer
![](https://koobas.hobune.stream/wayback/20220612202801im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Timer doesn't work properly 2 Answers
When Score goes up by 25 change timer value 1 Answer
Countdown Through a Label? 1 Answer
Countdown to start level 1 Answer
end game condition 1 Answer