- Home /
check if a timer value is between two numbers
I want a specific event to happen when a timer hits a particular value. However it is not detecting this so instead I thought I would check if it is between two values. How would I do this?
var timer:float = 0;
function Update(){
timer += Time.deltaTime;
if (timer > 10 < 11){
do something
}
}
Answer by BiG · Dec 07, 2011 at 10:12 AM
if (timer > 10 < 11) is syntactically wrong. That's:
if (timer > 10 && timer < 11)
Yep, program$$anonymous$$g languages work a bit differently then you would write it on a sheet of paper. Even then you would write it like this:
10 < timer < 11
otherwise it's not clear what you want. However for a computer it's an expression made up of two seperate conditions.
+1
Thanks Bunny, for the +1 and for an explanation better than $$anonymous$$e! :)
Answer by Tasarran · Dec 07, 2011 at 05:48 PM
The way I do a timer is to take the time, add the amount I want to delay, and store it in a variable.
Then, I periodically check to see if the current time is equal or greater than the stored variable.
Your answer
Follow this Question
Related Questions
Get integer or float value of a variable 2 Answers
How do I make an animation change based on an integers value. 2 Answers
Timer and TextMesh issue.... 1 Answer
Making an integer minimum value 0 2 Answers
Save Integer Values 1 Answer