How do I make a lerp function frame-rate independent without altering speed?

0 favourites
  • 5 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • Hey, I am trying to make everything in my game frame-rate independent, but I noticed that if I just multiply, say, the rate in a lerp function that is called every tick by dt, then it makes it much slower.

    Is there anything that I can always add/multiply to it in addition to multiplying it to dt to make it retain its speed? Right now I am just adding a certain amount to each individual instance with trial and error, but that is inefficient and not precise.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • lerp(current, target, 1-factor^dt)

  • lerp(current, target, 1-factor^dt)

    Thanks for the response. I tried this and it is much faster, but still a bit slower than it should be. Maybe this is because of performance when testing it while it was framerate-dependent? Anyway, changing it to lerp(current, target, 1.05-factor^dt) works, so should I just use 1.05 for all of them? Or do I need to change it for each lerp() individually? Thanks.

  • Not sure about going with 1.05... The 1 in the formula should stay constant afaik and I don't know about the ramifications. Maybe it's fine?

    This formula will be somewhat different to the framerate dependent lerp and you should adjust the factor accordingly. Basically the higher the factor, the slower the speed.(As opposed to the other way around) I found I'm having to use very small values to make it snappy, like 0.000000001

    But the point is it's framerate independent so even if it's slower than it should be, it will be so across all framerates.

  • Not sure about going with 1.05... The 1 in the formula should stay constant afaik and I don't know about the ramifications. Maybe it's fine?

    This formula will be somewhat different to the framerate dependent lerp and you should adjust the factor accordingly. Basically the higher the factor, the slower the speed.(As opposed to the other way around) I found I'm having to use very small values to make it snappy, like 0.000000001

    But the point is it's framerate independent so even if it's slower than it should be, it will be so across all framerates.

    Got it, thanks.

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