Created
April 13, 2018 12:22
-
-
Save aienabled/82f50f33c281b431e24091bd3813a5f5 to your computer and use it in GitHub Desktop.
Lerp with delta time for C#/Unity, based on https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.