Programmer:)

Lerp(선형 보간 함수) 본문

공부(개발)/c#

Lerp(선형 보간 함수)

ryeggg 2020. 2. 20. 16:55
반응형

 

public static Vector3 Lerp(Vector a, Vector b, float t);

Vector a 와 Vector b 사이의 float t를 반환한다.

 

주로 한 템포 늦게 플레이어를 따라가는 카메라를 구현할 때 사용한다.

위치,숫자,색 등을 부드럽게 변환할 때 유용하다.

 

ex)

//Move the gun to the zoom position

transform.localPosition= Vector3.Lerp(transform.localPosition,

zoomPosition, Time.deltaTime * moveSpeed);

//Change the camera field of view

gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView,

zoomFov,fovSpeed * Time.deltaTime);

 

반응형
Comments