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,497
Reputation: 81,682

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,123
Reputation: 17,150

Return to How do I....?

Who is online

Users browsing this forum: sbucci and 16 guests