Skip to content

Instantly share code, notes, and snippets.

@Anmol-1903
Last active March 25, 2026 03:14
Show Gist options
  • Select an option

  • Save Anmol-1903/286d875aa2bb5f543564b9f86296a37a to your computer and use it in GitHub Desktop.

Select an option

Save Anmol-1903/286d875aa2bb5f543564b9f86296a37a to your computer and use it in GitHub Desktop.

Lerp vs SmoothDamp — Unity

The Problem

Vector3.Lerp with a fixed t in Update() is NOT smooth movement. It approaches the target exponentially — slowing forever, never truly arriving.

The Solution

Vector3.SmoothDamp accelerates toward the target and decelerates on arrival. It actually reaches the destination with physically believable motion.

When to use what

  • Lerp — interpolating between two fixed values (colors, UI alpha, progress bars)
  • SmoothDamp — following a moving target (camera, UI element, character)

Unity Version

Compatible with any modern Unity version.

using UnityEngine;
public class LerpExample : MonoBehaviour
{
[SerializeField] private Transform target;
private float t = 0.05f;
void Update()
{
// Looks smooth but never actually arrives
// Slows down exponentially, approaching forever
transform.position = Vector3.Lerp(transform.position, target.position, t);
}
}
using UnityEngine;
public class SmoothDampExample : MonoBehaviour
{
[SerializeField] private Transform target;
[SerializeField] private float smoothTime = 0.3f;
private Vector3 velocity = Vector3.zero;
void Update()
{
// Accelerates toward target, decelerates on arrival
// Actually reaches the destination
transform.position = Vector3.SmoothDamp(
transform.position,
target.position,
ref velocity,
smoothTime
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment