๋ง์ฐ์ค ์ฐํด๋ฆญ ๋๋ฅด๋ฉด ํ๋ํ๊ณ ํ๋ ์ด์ด ๋ฌด๋น ๋ฐฉํฅ์ ๋ฐ๋ผ ๊ฐ์ด ์์ง์
Brackey ์ ํ๋ธ์์ ๋ฐฐ์ด bound ์์ฉํ๋ ์ฝ๋๋ผ
๋ ํ๋ฉด ์ด๋์ mathf.lerp์ smoothDamp๋ฅผ ์์ฉํ์
์ฐธ๊ณ ๋ก mathf.lerp๋ ๋ช๋ช ๋ด๋น๊ฐ
transform.position = Vector3.lerp(startPos, endPos, time.deltatime);
์ด๋ ๊ฒ ์ฐ๋ฉด ๋งค ํ๋ ์๋ง๋ค 0.02๊ฐ ๋จ์์ ์๋ฒฝํ๊ฒ endPos ์ ๋๋ฌํ์ง ๋ชปํ๋ค๋ ๊ฑฐ ํ๋ฒ์ฏค ๊ฒฝํํด๋ดค์๊บผ๋ค
๊ทธ๋ฌ๋ฉด ๋ณด๊ธฐ๊ฐ ์์ข์ผ๋๊น
float lerpTime = 1f; // endNum์ ๋๋ฌํ๊ณ ํ ์๊ฐ
float curLerpTime; // ํ์ด๋จธ ์ญํ ๋ด๋น
float Num = 0f;
float startNum = 0f;
float endNum = 1f;
์ด๋ ๊ฒ ํ๋๊ฐ์ ๋จผ์ ์ฃผ๊ณ ์ ๋ฐ์ดํธ ๋ฌธ์
// ํ์ด๋จธ ์์
curLerpTime += time.deltaTime;
if(curLerpTime > lerpTime) curLerpTime = LerpTime;
//Lerp
float perc = curLerpTime / lerpTime;
Num= Vector3.lerp(startNum, endNum, perc);
Debug.log(Num);
// 0.2 > 0.5 > 0.8 > 1
Num์ startNum์ผ๋ก ๋ฐ๊พธ๋ฉด ์ ๊ณฑ์ด ๋์ด์
// 0.1 > 0.8 > 0.9 > 0.99 > 1
์ด๋ ๊ฒ ๋จ
๋งํฌ
https://chicounity3d.wordpress.com/2014/05/23/how-to-lerp-like-a-pro/
๊ทผ๋ฐ ๋ค ํ์์๊ณ
๋ณ๊ฒ ๋ค ์๋ ๊ฐ์ย ์์
์ฐ์, ํน๊ฐ์์
๋ต๊ฒ ๊ณต์ง๋ค!
์์น์ค์