Hi there, i’m trying to create a small timer for an if statement, but not sure quite ow to measure the timer in seconds…
so something like this possibly.
public int timer = 0;
void update (){
timer = timer + 1;
timeFunction();
}
void timeFunction () {
if (time > 5){
//do something here
}
}
in that format… but i know that’s not going to count down 5 seconds… any idea of how to? thanks!
InvokeRepeating()
Then you can set how often timeFunction is called.
With update it will be called every 33 milliseconds or something rediculous.
reading the page for it in the manual… i’m not sure in what context i would use that in for an if statement…
the way they use it is like this :
public int timer = 0;
void update (){
timer = timer + 1;
timeFunction();
}
void timeFunction () {
if (time > 5){
//do something here
}
}
void repeater(){
InvokeRepeating("TimeFunction", 5, 0.5F);
}
something like that? i’m not sure i fully understand how that is to be used properly.
what about Time.DeltaTime ?