# Use timer like we use object variable!

I wanna use timer like we use object variable. I wanna set a timer but i wanna use it as object variable different for all different objects. How can I do that?

To do that, you can’t really use timers but you can use an object variable that you increase over the time : you just need to Do +TimeDelta() to the variable myCustomTimer of Object. The variable will contain the time elapsed as seconds and you can use conditions to test the time.

That’s good. OK now what I want is that variable to increase by 1 (+1) every second or so, how to? Cuz what I want is this variable to loop itself form 1 to 10. it start from one and end at 10 and then start from one again. I know how to set that variable from 1 to 10 in a loop but I don’t know how to add 1 every second in that variable.

You can have real second, but you try a formula which will be close… the problem is that timedelta is the unit of time between two frames, so it’s depending on the computer you use to run the game.

Maybe you can try +TimeDelta()*0.xx and “round it” with mathematics functions to have value from 1 to 10.

I didn’t understand how to do that? I have tried it “+TimeDelta()*0.xx” and also round it using maths function. How exactly I have to do. Please!

Try this:

For each object, Do +1*TimeDelta() to increase the object variable by 1.
For each object, if the object variable greater or equal to 10, set variable to 0

It’s not 10 seconds exactly but the elapsed time 0 to 10 should be the same on all device by multiplying the value by TimeDelta().

how to Round TimeDelta or Variable without using another variable?

You need two variable : one that contains the sum of all TimeDelta() and another that is the round of the previous.

I have used this technique, but as a result all enemies are reacting at the same time. that’s why I need a way to round one variable with out using another variable? And, for your information, all variable I am using are object variable.

You need a “For each” event so that each object is treated one by one (so that round(MyObject.Variable(myVar) will give only the value of one enemy object).

Where is that condition. there is on condition that say. consider objects (pick all objects). I have tried that too.

It not a condition, it a special event ‘for each object’.
You can find it here: