Every X seconds problem

  • Hi, I have a group with one "every 5 seconds do x" in it.

    The problem is, when I want to start the 5 seconds going, the first call is usualy instant, and the second one follows very soon after. At least the first call is anywyere between 0 and 5s, the following onces are 5 seconds appart.

    I have tried various methods to "start" the 5s timer when i need it to start. I have put it in a group, and tried enabling and disabling, this did not help.

    I added a condition, and set that condition to true when I want the ever 5 seconds to start, but that didnt help.

    So I'm a bit stuck on how to get it to start such that from point X, 5s later, the first action of the every 5 s will be called.

  • if you want more control, perhaps just use a variable. Add 60*dt (1 a second basically) to a variable then check when it is greater than 300 (i think thats 5 seconds) then do what you wanted to do as actions then subtract 300.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another possibility is using a modulus operation, for instance if you wanted the condition to trigger every 60 seconds:

    Compare Values: round(time)%60 == 0

    time > 0

    -> Do something

  • Remember game seconds are affected by framerate, that's what dt are for :D

  • The new Timer behaviour gives you complete control over starting/stopping.

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