Skip to content

Instantly share code, notes, and snippets.

@aienabled
Created April 13, 2018 12:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aienabled/82f50f33c281b431e24091bd3813a5f5 to your computer and use it in GitHub Desktop.
Save aienabled/82f50f33c281b431e24091bd3813a5f5 to your computer and use it in GitHub Desktop.
// see https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
public static double LerpWithDeltaTime(double a, double b, double deltaTime, double rate)
{
return Lerp(b, a, Math.Pow(2, -rate * deltaTime));
}
// see https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
public static float LerpWithDeltaTime(float a, float b, float deltaTime, float rate)
{
return Lerp(b, a, Math.Pow(2, -rate * deltaTime));
}
@slembcke
Copy link

Just use Mathf.Exp(). The exponent doesn't really matter. You'll just end up with a different rate value (which is hand tuned anyway), and Exp() is almost definitely faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment