How do I create an accurate timer with a precision of 0.001

Get help using Construct 2

Post » Wed Sep 10, 2014 5:48 am

Hey guys,

I followed instructions given in another thread to create a timer by adding 0.001 to a global variable every 0.001 seconds. With the fact in mind that "every" event is framerate independent it should be that after 1 second the value of the variable is 1.000 as well. But instead it is 0.6 (sometimes 0.58).

Obviously there is something I dont understand or in other words what is the max accuracy I can expect and it depends on what?


Thanks in advance
Posts: 8
Reputation: 237

Post » Wed Sep 10, 2014 6:24 am

Anything lower than "every 0.016 seconds" is the same as "every tick". You could instead add dt to the variable every tick and after 1 second the value will be very close to 1.
Posts: 5,272
Reputation: 69,455

Post » Wed Sep 10, 2014 12:20 pm

Framerate independancy in C2 is not as correct as you describe it. Basically you are still limited by the dt value (non trigger events are checked every tick, the every 0.001s can only be checked every ticks, aka every dt seconds) the closest you can get to have a framerate independant is to increase by an amount of dt every tick, that will still only increase it every ticks only, but of the good value.

PS: so you have two limitations: the game can be framerate independant as long as you do not try to have times shorter than dt, and as long as the fps value is superior to 10.
Game design is all about decomposing the core of your game so it becomes simple instructions.
Posts: 2,122
Reputation: 17,123

Return to How do I....?

Who is online

Users browsing this forum: Construct Monkey, David181, dop2000, luckyrawatlucky and 5 guests