갬장장이
'mathematics' 카테고리의 글 목록 (5 Page)

mathematics

mathematics/game mathematics

Linear Interpolation (선형 보간)

*interpolate (약어 lerp) 구현방법1. Approach 함수 Approach(G, C, dt) if G - C > dt: return C + dt if G - C < -dt: return C - dt else: return G 매 게임 프레임마다 Approach()의 결과값을 다시 Approach의 C값에 집어넣는다. 그러면 G에 dt씩 근접해간다. (dt를 더할 수도 뺄 수도 있다) 실제 사례에 적용 - WASD로 이동할 때 그냥 바로 캐릭터의 velocity를 상수로 바꿔버리면 움직임이 부자연스럽다. 따라서 WASD를 눌렀을 때 VelocityGoal을 상수로 설정하고, 매 프레임(Update())마다 Approach(캐릭터.velocity, 캐릭터.velocityGoal, dt)를 실..