← All packages
Smooth Pro
Unity 프레임 레이트 독립 스무딩. Unity 가장 흔한 실수에 대한 드롭인 수정:
매 프레임 Lerp(value, target, 0.1f) 사용.
문제
잘못됨 (프레임 레이트 의존적)
// 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);
수정됨 (프레임 레이트 독립)
// 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);
빠른 시작
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); // --- 스프링 댐퍼 --- // 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);
지수 스무딩 - Smooth
정적 클래스. float, Vector2, Vector3, Quaternion, Color에 대한 모든 메서드 오버로드.
| Method | Description |
|---|---|
Smooth.Exp(value, target, speed, dt) | exp(-speed * dt)를 사용한 지수 스무딩. 핵심 수정. |
Smooth.ExpHalfLife(value, target, halfLife, dt) | 동일한 수학, 초 단위 반감기로 매개변수화. 디자이너 친화적. |
Smooth.ExpAngle(value, target, speed, dt) | 각도 인식 버전. 0/360 랩을 올바르게 처리. |
Smooth.SpeedFromBrokenLerpT(t, fps) | 기존의 잘못된 lerp t값을 참조 fps에서 올바른 속도로 변환. |
Smooth.ConvergenceTime(speed, pct) | 주어진 퍼센트(기본 99%) 수렴에 도달하는 시간. |
스프링 댐퍼 - Spring
프레임 레이트 안정성을 위한 적응형 서브스테핑이 포함된 2차 스프링 동역학. float, Vector2, Vector3 오버로드.
| Method | Description |
|---|---|
Spring.Critical(val, target, ref vel, freq, dt) | 임계 감쇠. 오버슈트 없는 가장 빠른 수렴. |
Spring.Bouncy(val, target, ref vel, freq, bounciness, dt) | 설정 가능한 바운스 (0-1)의 탄성/스프링 느낌. |
Spring.Damped(val, target, ref vel, freq, damping, dt) | 임의 감쇠비의 일반 2차 스프링. |
이징 함수 - Ease
30개 이상의 표준 곡선. 각각 In, Out, InOut 변형으로 제공.
| 패밀리 | 곡선 |
|---|---|
| Polynomial | Quad, Cubic, Quart, Quint |
| Trigonometric | Sine |
| Exponential | Expo, Circ |
| Overshoot | Back, Elastic, Bounce |
| Hermite | SmoothStep, SmootherStep (Perlin variant) |
Ease.Lerp(start, end, t, EaseType) 이징 + 보간을 한 번의 호출로 결합.
Editor tools
Window > DAWG Tools > Smooth Inspector
- 지수 모드 - 30/60/144fps에서 naive Lerp vs Smooth.Exp의 나란히 그래프. 프레임 레이트 의존성을 시각적으로 확인.
- 스프링 모드 - 바운시 설정의 오버슈트, 정착 시간, 링잉을 보여주는 응답 곡선 시각화.
- 이징 모드 - 30개 이상의 이징 함수에 대한 곡선 형태 미리보기.
- dt 스트레스 테스트 - 일정 FPS, 지터 프레임, FixedUpdate, 커스텀 틱 레이트에서 스무딩 테스트.
- 마이그레이션 도우미 - 기존의 잘못된 lerp 값을 올바른 지수 속도로 변환. 복사-붙여넣기 가능한 코드.
설치
// 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. 외부 의존성 없음.