Problem with Delta Time

0 favourites
  • 4 posts
From the Asset Store
Time Rewind
$0.50 USD
95% off
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • I've been working on a project for quite awhile, and send some test versions out to friends just to be noted that the game works waay to fast on other computers (nw.js exported version). Did googling and figured i have to set everything to delta time, and had a basic understanding of how it works.

    My problem comes with adding/substracting values with delta time, as they are not rounded numbers anymore. I got alot of events that rely hitting those precise numbers, and with delta time they get bypassed. I tried rounding the delta time, but that brought incredible amount of unexplainable glitches to the game.

    I got some basic things working simply using "equal or less" on hitting those values, but that's not an option on everything, as there might be multiple values to hit. How do people work around with this?


  • For something simple like variable that only increases or decreases you can utilize the trigger once condition.

    Variable timer = 10

    Every tick

    — subtract 123*dt from timer

    Timer <= 7.5

    Trigger once

    — set text to “three quarters left”

    Timer <= 1/3

    Trigger once

    — set text to “a third left”

    Timer <= 0

    Trigger once

    — set text to “done”

    Something that counts up would be >= instead.

    Another option could be to still change the variable by whole numbers but use a dt multiplied one to control it.

    Variable timer =0

    Variable countdown = 10

    Every tick

    — add 100*dt to timer

    Repeat int(timer) times

    — subtract 1 from timer

    — subtract 1 from countdown

    — if countdown=5

    — — set text to “halfway”

    — if countdown = 2

    — — set text to “a fifth left”

    — if countdown = 0

    — — set text to “done”

    Anyways those are two ideas that come to mind.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Those are both great examples on those R0J0hound! I didn't even think about the trigger once function, or to utilize it like that. Both examples work, but there is still some issues. If you take a whole number from delta, it rounds it to 1 on occasions, so i don't reach 0 which im looking for. One way i thought of dealing with it, is to just let it substract lower than 0. Say to -5. And on 0 it can do whatever it's necessary to do.

    It's still alot of work to implement to the game, i guess there is no fast fix to it, because there is ALOT of events involved i have to start changing up.

  • Guess it would be tricky converting everything over. Usually I just round as a last step and keep the unrounded variable and apply all changes to that.

    Anyways, here’s another idea to convert it. I’m assuming on your machine it runs at 60fps, so if you put all your events as sub-events to this it may work. It just only runs when the time passed is a 1/60th of a second. Just an idea at least. Triggers and new object picking may throw it off.

    Variable prevtime=0

    Compare: prevtime+1/60 <= time

    — add 1/60 to prevtime

    — put all events here

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