How to make personalized counter/timer using dt?

  • So I am trying to make a cool down timer, and have set the variable customTimer to 0, and if customTimer >0, then add dt to customTimer every tick. As I understand it, if I do it this way, after every second, the value of customTimer should be pretty close to 1.0. However, sometimes, the timer is really slow and takes 1.5 seconds to reach 1.0. Why is it like this?

  • dt*60 will result 1 every second

  • If your frame rate is dropping below 10 fps then this will make your timer slow ?

    Have you looked at the timer behaviour to do this delay ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 7Soul you're answer is so short that it looks wrong (:

    wp2000 for some (probably good) reasons I didn't have the motivation to investigate, c2 doesn't allow dt to be greater than 0.1s, if your game is slower than 10 fps, dt will then be wrong.

    on 60 fps -> dt = 1/60 = 0.017 so after 60 frames of adding dt you get 1 (probably what 7Soul meant)

    on 10 fps -> dt = 1/10 = 0.1 after 10 frames you get 1 as well

    on 5 fps -> dt = 1/10 = 0.1 after 5 frames you only get 0.5 and that's probably your issue

    The work around is to compute your own dt value using the wallclocktime system property.

    I made a practical example few days ago: hiddenObjectClock.capx

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