- Home /
Question by
AntacidCarcass · Apr 17, 2018 at 09:07 PM ·
timerfloattimer-script
Change Float Value
How can I change a floats Value when it reaches a certain number? Right now I have to wait 5 seconds and once it reaches 0 the script works but the time is supposed to restart. So how do I get it to go from 0 back to 5 seconds?
Comment
You will need to post a bit more information in order for someone to help you. :-\
can you post your script, and a little more info for the us to assist you?
Answer by Serinx · Apr 17, 2018 at 10:55 PM
I imagine you want something like this? You'll have to be more descriptive if not.
float timer = 5f;
void Update()
{
timer -= Time.deltaTime;
if (timer <= 0f) //Check if the timer has reached 0
{
//Do something
timer = 5f; //Reset the timer
}
}