← All packages

Smooth Pro

Suavizado independiente del frame rate para Unity. La corrección directa para el error más común de Unity: usar Lerp(value, target, 0.1f) cada frame.

v1.1.0 Unity 2021.3+ No dependencies namespace: DawgTools.Smooth

El problema

Roto (dependiente del frame rate)

// This runs every frame with a fixed 10% step.
// At 30fps: 30 steps/sec. At 144fps: 144 steps/sec.
// Players on faster machines see faster smoothing.
value = Mathf.Lerp(value, target, 0.1f);

Corregido (independiente del frame rate)

// Same behavior at any frame rate.
// Uses exp(-speed * dt) which naturally
// compensates for variable frame times.
value = Smooth.Exp(value, target, 10f, Time.deltaTime);

Inicio rápido

using DawgTools.Smooth;

// --- Exponential smoothing ---

// Direct replacement for broken Lerp
transform.position = Smooth.Exp(transform.position, target, 10f, Time.deltaTime);

// Designer-friendly: "halfway to target in 0.2 seconds"
value = Smooth.ExpHalfLife(value, target, 0.2f, Time.deltaTime);

// Angle-aware (handles 0/360 wrap correctly)
angle = Smooth.ExpAngle(angle, targetAngle, 8f, Time.deltaTime);

// --- Amortiguadores de resorte ---

// Critically damped: fastest convergence, no overshoot
pos = Spring.Critical(pos, target, ref velocity, 5f, Time.deltaTime);

// Bouncy: overshoots and oscillates
scale = Spring.Bouncy(scale, targetScale, ref scaleVel, 8f, 0.5f, Time.deltaTime);

// --- Migration ---

// Convert your existing broken lerp value to correct speed
float speed = Smooth.SpeedFromBrokenLerpT(0.1f, 60f); // ~6.32

// --- Easing ---

float t = Ease.InOutCubic(progress);
value = Ease.Lerp(start, end, progress, EaseType.InOutElastic);

Suavizado exponencial - Smooth

Clase estática. Todos los métodos sobrecargados para float, Vector2, Vector3, Quaternion y Color.

MethodDescription
Smooth.Exp(value, target, speed, dt)Suavizado exponencial usando exp(-speed * dt). La corrección principal.
Smooth.ExpHalfLife(value, target, halfLife, dt)La misma matemática, parametrizada por vida media en segundos. Amigable para diseñadores.
Smooth.ExpAngle(value, target, speed, dt)Versión consciente de ángulos. Maneja correctamente el wrap 0/360.
Smooth.SpeedFromBrokenLerpT(t, fps)Convertir valor t de lerp roto existente a velocidad correcta en un fps de referencia.
Smooth.ConvergenceTime(speed, pct)Cuánto tiempo para alcanzar un porcentaje dado (por defecto 99%) de convergencia.

Amortiguadores de resorte - Spring

Dinámica de resorte de segundo orden con sub-stepping adaptativo para estabilidad de frame rate. Sobrecargado para float, Vector2, Vector3.

MethodDescription
Spring.Critical(val, target, ref vel, freq, dt)Críticamente amortiguado. Convergencia más rápida sin overshoot.
Spring.Bouncy(val, target, ref vel, freq, bounciness, dt)Sensación elástica/resorte con rebote configurable (0-1).
Spring.Damped(val, target, ref vel, freq, damping, dt)Resorte de segundo orden general con razón de amortiguamiento arbitraria.

Funciones de easing - Ease

30+ curvas estándar. Cada una disponible como variantes In, Out e InOut.

FamiliaCurvas
PolynomialQuad, Cubic, Quart, Quint
TrigonometricSine
ExponentialExpo, Circ
OvershootBack, Elastic, Bounce
HermiteSmoothStep, SmootherStep (Perlin variant)

Ease.Lerp(start, end, t, EaseType) combina easing + interpolación en una llamada.

Editor tools

Window > DAWG Tools > Smooth Inspector

  • Modo exponencial - Gráfico lado a lado comparando Lerp naive vs Smooth.Exp a 30/60/144fps. Ve la dependencia del frame rate visualmente.
  • Modo resorte - Visualización de curva de respuesta mostrando overshoot, tiempo de asentamiento y ringing para configuraciones bouncy.
  • Modo easing - Vista previa de forma de curva para las 30+ funciones de easing.
  • Prueba de estrés dt - Prueba tu suavizado bajo FPS constante, frames con jitter, FixedUpdate y tick rates personalizados.
  • Asistente de migración - Convierte tus valores lerp rotos existentes a velocidades exponenciales correctas. Código listo para copiar y pegar.

Instalación

// Unity Package Manager > Add package from disk
// Navigate to package.json and select it

// Then import the demo scene:
// Package Manager > Motion Smoothing Pro > Samples > Import

Requires Unity 2021.3 LTS or newer. Sin dependencias externas.