SmoothDamp
https://docs.unity3d.com/kr/530/ScriptReference/Vector3.SmoothDamp.html
Unity - 스크립팅 API: Vector3.SmoothDamp
The vector is smoothed by some spring-damper like function, which will never overshoot. 가장 일반적인 용도는 따라오는 카메라를 부드럽게 하려는 것입니다.
docs.unity3d.com
Lerp에 관해 찾다가 SmoothDamp 쓰는걸 권장하는 글을 많이봐서 찾아봤다.
Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime)
current : 현재 위치
target : 도달하려는 위치
currentVelocity : 현재 속도, 이 값은 매번 이 함수가 호출될때마다 변경됨
smoothTime : target에 도달하기 위한 대략적인 시간. 즉 작은값일수록 target에 빨리 도달.
currentVelocity는 update문 내의 SmoothDamp가 호출될때마다 값이 변경된다.
debug.log로 찍어봤더니 다음과 같이 값이 변경됐다.
보면 velocity값이 점점 작아지다가 0이 되는걸 볼수있다.
target에 가까워질수록 오브젝트의 속도가 느려지다가 target에 도달하면 0이 된다.
smoothTime은 target에 도달하기 위한 대략적인 시간인데, 실제로 파라미터를 5f로 줘도 정확히 5초에 도달하는것은 아니고 대략적인 시간을 나타내는것 같다.