Correct way to use dtime in this situation?

  • I got things to work, but in a different way, so I am curious what the correct way is to use delta time with multiplication like this. Should have been simple, but it did not work.

    ObjectX = ObjectX + speed dt here is basically Object.X + speed*dt or (speed*60)*dt if redoing an older game that used speed that worked at 60 frames per second without using dt.

    Now I want to simulate drag so I decrease speed every tick by multiplying it by 0.99

    speed = speed*0.99 So what is the correct way to use delta time here?. doing things like 0.99*dt do not work.

    Anyway, I got it to work with something like this lerp(speed,speed*0.99,1-0.0999^dt). It does work, but it just seems like a hack that should not really work

    Just to add. You have to test it with this new beta feature and run full frames, not v-sync

  • I probably need a refresher on my computer math.

    ((object.x+speed*0.99)*dt)

    Dt should be the final thing that everything else is multiplied by.

  • Actually I should change that. Its should always just be speed*dt.

    (object.x+speed*dt)*0.99

  • That is what I had originally, but in 2 actions

    object.X = object.X + speed*dt

    speed = (speed*0.99)*dt

    Tried a couple of variations and your example, does not work

    The second way you wrote it does seem to work at 60FPS, but it does not work at full frame setting. I think 0.99 needs to be dtimed somehow, otherwise you are multiplying by 0.99 twice or three times as fast at full frames setting

  • Don' know if this is a bug but:

    + System: Every tick

    -> System: Set speed to speed×dt

    is always 0 independently of the start size of speed.

  • You want to look at it as "what if dt was zero?".

    If it was zero it would be zero speed.

    Otherwise dt will generally be between 0, and 0.16.

    The time since the last tick.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've seen some weird stuff there too ( in some variations of these formulas ). Speed not decreasing at all despite being multiplied by 0.99

    Well, like I said in the original post, feels like a hack, but this works in my game, v-synced or full frame setting

    lerp(speed,speed*0.99,1-0.0999^dt)

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