I'm working on a multiplayer game that for the purposes of this question, is most similar to Team Fortress.
Each network data packet will contain the 3D position of the target moving object. (this object could be another player) The packets are sent on a fixed interval, and linear interpolation will be used to smooth the transition between packets. Under normal circumstances, interpolation will occur between the second-to-last packet, and the last packet received.
The linear interpolation algorithm is the same as this post:
I have the same issue as in that post, but the answers don't seem like they will work in my situation. Consider the following scenario:
- Normal packet timing, everything is okay
- The next expected packet is late. That's okay, we'll just extrapolate based on previous positions
- The late packet eventually arrives with corrections to our extrapolation. Now what do we do with its information?
The answers on the above post suggest we should just interpolate to this new packet's position, but that would not work at all. If we have already extrapolated past that point in time, moving back would cause rubber-banding.
The issue is similar in the case of an early or dropped packet.
So I believe what I am looking for is some way to smoothly deal with new information in an ongoing interpolation/extrapolation process.
Since I might be moving on to quadratic or even cubic interpolation, it would be great if the same solutiuon could be applied to those as well.