# What's the difference between Mathf.Lerp and Mathf.SmoothDamp

I want to smoothly go from one value to a new one (moving a slider or changing color). I tried using both functions and they all basically give the same result. What is the difference between them and which one should I use?

How I used SmoothDamp:

    // Show the HUD
private IEnumerator ShowHUD() {
var HUDCanvasGroup = GameObject.FindWithTag("HUD").GetComponent<CanvasGroup>();
var alphaValue = 1f;
var velocity = 0f;
var time = 0.30f;

yield return new WaitForSeconds(1.5f);

while (!Mathf.Approximately(HUDCanvasGroup.alpha, alphaValue)) {
HUDCanvasGroup.alpha = Mathf.SmoothDamp(HUDCanvasGroup.alpha, alphaValue, ref velocity, time);
yield return null;
}

HUDCanvasGroup.alpha = 1; // Since float is not accurate, manually set the alpha to 1 after
HUDCanvasGroup.interactable = true;

var blur = GameObject.FindWithTag("BlurryCamera").GetComponent<BlurOptimized>();
blur.enabled = true;
}


How I used Lerp:

public static IEnumerator Dim() {
while (t < 1) {
t += Time.deltaTime / 0.4f;
dimRend.material.color = Color.Lerp(undimColor, dimColor, t);
yield return null;
}
}

• BTW you are using Color.Lerp that interpolates between color instead of values – Hamza Hasan Feb 7 '16 at 17:25
• @HamzaHasan It's on the same principle. – Milen Pivchev Feb 7 '16 at 17:43

The mechanical difference is that Lerp is linear, while SmoothDamp follows a sigmoid function. See How to Lerp like a pro and Smoothstep for more in-depth explanation and graphs.
In terms of which one you should use, that varies from product to product, situation to situation. SmoothDamp-style is often more pleasant to the eye, especially for slower fades in/out, or where the thing being interpolated is intended to be seen as physical. I.e. SmoothDamp motion generally looks more like the object is accelerating and decelerating, rather than suddenly starting and stopping.
The linear fade of Lerp works well for very fast fades, and is (I expect) slightly quicker to compute. So, if you're doing an enormous amount of interpolation, Lerp might better suit your needs. Again, however, it can look unnatural for things that are physical.