Unity 게임 루프에서 frame과 fixed step 나누기
Update·FixedUpdate·LateUpdate의 시간 계약을 구분하고, input sampling·physics simulation·render follow를 섞지 않는 방법입니다.
Vector2 pendingMove;
void Update()
{
pendingMove = ReadMoveInput(); // 최신 input을 frame마다 수집
}
void FixedUpdate()
{
body.AddForce(new Vector3(pendingMove.x, 0f, pendingMove.y) * acceleration);
}
void LateUpdate()
{
cameraRig.Follow(body.position); // simulation 뒤 화면 갱신
}