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

  • 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?

    Suggestions?

    Thanks in advance

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)