DAWG Tools - Smooth PRO
Most Unity projects have code like this:
current = Mathf.Lerp(current, target, 0.1f);
It runs every frame, applying a fixed percentage step toward the target. At 30 FPS it applies 30 times per second. At 144 FPS it applies 144 times per second. Players on faster machines see faster smoothing.
The fix is one line:
current = Smooth.Exp(current, target, 10f, Time.deltaTime);
Same behavior at every frame rate. The math uses exp(-speed * dt) which naturally compensates for variable frame times.
Use cases: camera systems, UI motion and transitions, gameplay parameter smoothing, audio interpolation, network / multiplayer interpolation.
WHAT'S INCLUDED
Exponential Smoothing (Smooth class)
- Smooth.Exp — frame-rate independent exponential smoothing
- Smooth.ExpHalfLife — parameterized by half-life (designer-friendly: "halfway to target in 0.2 seconds")
- Smooth.ExpAngle — wrap-safe angle smoothing (no snapping at 0/360)
- Overloads for float, Vector2, Vector3, Quaternion, Color
Spring Dampers (Spring class)
- Spring.Critical — fastest convergence, no overshoot
- Spring.Damped — general-purpose, any damping ratio
- Spring.Bouncy — configurable overshoot and oscillation
- Overloads for float, Vector2, Vector3
- Adaptive substepping for frame-rate stable results
Easing Functions (Ease class)
- 30+ standard curves: Quad, Cubic, Quart, Quint, Sine, Expo, Circ, Back, Elastic, Bounce
- In / Out / InOut variants for each
- SmoothStep and SmootherStep (Hermite / Perlin)
- Ease.Lerp helper combining easing + interpolation
Conversion Utilities
- SpeedFromBrokenLerpT — convert existing lerp t values to correct speed
- SpeedFromHalfLife / HalfLifeFromSpeed
- ConvergenceTime — time to reach 90%, 99%, etc.
Editor Window (Window > DAWG Tools > Smooth Inspector)
- Three modes: Exponential, Spring, Ease
- Exponential: side-by-side graph of naive lerp vs Smooth.Exp at different frame rates
- Spring: response curve visualization showing overshoot for bouncy settings
- Ease: curve shape preview for all easing functions
- dt profile stress test (constant FPS, jittered frame times, FixedUpdate simulation, custom tick rates)
- Convergence analysis, migration helper, copy-to-clipboard snippets
EXAMPLES
Camera follow:
// Before (frame-rate dependent)
transform.position = Vector3.Lerp(
transform.position,
target.position,
followSpeed * Time.deltaTime
);
// After (consistent at any FPS)
transform.position = Smooth.ExpHalfLife(
transform.position, target.position,
0.15f, Time.deltaTime);
UI fade (works during frame drops and with timescale = 0):
canvasGroup.alpha = Smooth.ExpHalfLife(
canvasGroup.alpha, targetAlpha,
0.08f, Time.unscaledDeltaTime);
Rotation (no snapping at 0/360 boundary):
currentYaw = Smooth.ExpAngle(
currentYaw, targetYaw,
Smooth.SpeedFromHalfLife(0.12f),
Time.deltaTime);
Spring motion:
position = Spring.Critical(
position, target,
ref velocity, 5f,
Time.deltaTime);
Easing:
float t = elapsed / duration;
float eased = Ease.OutCubic(t);
value = Mathf.LerpUnclamped(start, end, eased);