[UE5] ๐Ÿ“ˆ Lerp

Singery00ยท2024๋…„ 5์›” 16์ผ
0

UE5

๋ชฉ๋ก ๋ณด๊ธฐ
10/37
post-thumbnail
post-custom-banner

๊ฐœ์š”

๐Ÿ“ˆ ํƒ€์ž„๋ผ์ธ๊ณผ ์ง๊ฟ์ฒ˜๋Ÿผ ์‚ฌ์šฉ๋˜๋Š” ๋…ธ๋“œ์ธ Lerp์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž.

์–ธ๋ฆฌ์–ผ์—์„œ๋Š” ์•กํ„ฐ์˜ Transform์„ ์กฐ์ ˆํ•˜๊ธฐ ์œ„ํ•ด TimeLine์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

์‹œ๊ฐ„๊ฐ’์„ ์ •ํ•˜๊ณ , ์„ค์ •ํ•œ ๊ทธ๋ž˜ํ”„๋ฅผ ๋”ฐ๋ผ ์ ์ ˆํ•œ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์ด๋•Œ ๋ฐ˜ํ™˜๊ฐ’์„ ๋ณดํ†ต Alpha๋ผ๊ณ  ํ•˜๋Š”๋ฐ Alpha๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ณด๊ฐ„์„ ํ†ตํ•ด ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“ค์–ด ์ฃผ๋Š” ๋…ธ๋“œ๊ฐ€ Lerp์ž…๋‹ˆ๋‹ค.

์–ธ๋ฆฌ์–ผ Lerp ๊ณต์‹ ๋ฌธ์„œ


๋ณธ๋ก 


๐Ÿ“ˆ Lerp

Lerp๋Š” Linear Interpolation์˜ ์•ฝ์ž๋กœ '์„ ํ˜• ๋ณด๊ฐ„๋ฒ•'์ด๋ผ๋Š” ๋œป์ž…๋‹ˆ๋‹ค.

Lerp๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ Lerp๊ฐ€ ๋‚˜์˜ค๋Š”๋ฐ Float ๋…ธ๋“œ๋ฅผ ๋Œ€ํ‘œ๋กœ ์„ค๋ช…ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ‘
![](https://velog.velcdn.com/images/singery00/post/2


Lerp ๋…ธ๋“œ ์„ค๋ช…

Lerp ๋…ธ๋“œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ A,B,Alpha 3๊ฐœ์˜ Input์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

Input A

A๋Š” Alpha ๊ฐ’์ด 0์ผ ๋•Œ 100%๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.

Input B

B๋Š” Alpha ๊ฐ’์ด 1์ผ ๋•Œ 100%๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.

Input Alpha

Alpha ๊ฐ’์€ 0~1 ์‚ฌ์ด์˜ ๊ฐ’์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

0~1 ์‚ฌ์ด ๊ฐ’์„ A~B ์‚ฌ์ด ๊ฐ’์œผ๋กœ ๋ณด๊ฐ„ํ•ด์ฃผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋งŒ์•ฝ A๋Š” 0, B๋Š” 10์ด๋ผ๊ณ  ํ•  ๋•Œ, Alpha์˜ ๊ฐ’์— ๋”ฐ๋ผ ์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๊ฐ’์ด ๋‚˜์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

Alpha 0 = 0
Alpha 0.2 = 2
Alpha 0.5 = 5
Alpha 0.75 = 7.5
Alpha 1 = 10


๋งˆ๋ฌด๋ฆฌ

Timeline์˜ ๋ฐ˜ํ™˜๊ฐ’์ด Float, Vector, Color ๋“ฑ์ด ์žˆ๋Š”๋ฐ ํ•ด๋‹น ๋ฐ˜ํ™˜ ๊ฐ’์— ๋งž๋Š” FLerp, VLerp ๋“ค์ด ์ค€๋น„๋˜์–ด ์žˆ์œผ๋‹ˆ ์ ์ ˆํ•˜๊ฒŒ ์ž˜ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

profile
๊ฒŒ์ž„ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜์–ด๋ณด์ž
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€