Categories
Game Development

Slippery tail interpolation

I’m having a problem with high latency players jumping around a lot. Originally, I would extrapolate your position when a message came in. I would then do a lerp over some fixed amount of time between your current visual position and your new extrapolated position. This is accurate in that you see where the object […]

I’m having a problem with high latency players jumping around a lot.

Originally, I would extrapolate your position when a message came in. I would then do a lerp over some fixed amount of time between your current visual position and your new extrapolated position.

This is accurate in that you see where the object currently is. The problem is that when you suddenly change directions there is a hop.

Suppose I am moving y+10 per second and 100 milliseconds later I move y-10 per second. If the sender’s plus my own latency is 1 second, I would see that object 10 units up, then 100 milliseconds 10 units down. A huge hop.

I thought about this a long time and I came up with what I call slippery tail interpolation, although likely this isn’t novel and there’s a real name for it. But it just gives me the impression of holding onto a snake with oil on its tail and the tail keeps moving around.

I keep a transformation history of your position, orientation, and velocity for the last second. I also locally update your transformations based on your current velocity, acceleration, and rotational velocity. However, when a network message arrives, this negates part of the history (the slippery tail). So I recompute where you should have been over that amount of time, and rewrite history. My movement is complex, with a maximum velocity and a constant rotation which changes your thrust angle. I can’t think of any mathematical way to calculate your final position, so I just integrate over a fixed timestep.

Visually, I lag behind by half the sender’s average ping plus half your own average ping. This is the edge of the tail, just before the slippery part. So as history is rewritten, it is not likely to change what you see, only what you will see, and hence there is no popping around. However, if due to ping variances a message is so far in the past that it changes what we see, then I do linear interpolation.

Hopefully this will work. The hard part is going to be testing it. I’m also a little concerned that if you see everything slightly in the past it’s going to make gameplay less accurate. I might have a tweak where I move up the tail a bit so there’s some hopping but then visual positions are more accurate. Another possibility is to hit detection based on your past state.

Leave a Reply

Your email address will not be published. Required fields are marked *