Im trying to make a lerp function on an online game. Im doing this by having a buffer list, I append each server update to a list, and lerp over the contents, here is an example:
movementBuffer.unshift(gameUpdate); //when a new update is received
//in the main loop
timeElapsed += delta;
lerpPerc = timeElapsed / updateRate; //percent which is lerped to
if(lerpPerc > 1){ //when the lerp is finished, the states that were just lerped are removed from the buffer
mo
Seems like you are removing 2 items from the buffer while only adding 1 every update tick. When you are lerping 1-2, and 3 comes, you start lerping 2-3, so you should only remove 1.
Also this way you will get a bit jittery movement, because if the `lerpPerc > 1`, you are actually discarding the remainder. You would need to roll it off otherwise the position will seemingly go back in time. But to achieve smoothness in that, you need bigger interpolation period than one update tick. Packet