Predicting Remote Clients & Smoothing

Started by
4 comments, last by Kylotan 1 year, 3 months ago

Couldn't find much on this topic online, so here we go:

Suppose you have a game like rocket league. I've never played the game, but I've seen videos of it being played. It's really smooth. I'm gonna go ahead and assume that each client is predicting the ball and every other player in the game. The question is, how do they get it so smooth?

If you're predicting a player's car to be turning right, but it's actually turning left in that time, surely you'd have some pretty jarring corrections right? The only way I could think of solving this problem is by buffering the states the same as we do with remote entity interpolation. That way the visual car is going to lag behind the actual real time predicted physics car to provide some extra smoothing and maybe insert some extra artificial states in between, if the correction is too large. To make myself extra clear, I'm not talking about interpolating between the last/current predicted state. I'm talking about actually keeping a longer buffer so that I can insert artificial states halfway between the predicted position and the corrected position if they're too big of difference. And then interpolate normally at the framerate.

I look forward to reading the responses.

Edit: After thinking about this for a while, maybe I was completely wrong in my text above. I think I'm overestimating the amount of misprediction that can happen from a car turning it's wheels. Perhaps interpolating between last and current simulated states @ the tick accumulation % might be the only way to do it. If the visual is lagging behind too much like I originally wrote, that kinda just defeats the purpose of predicting other clients in the first place.

Advertisement

Corrections don't necessarily need to be jarring.

A long time ago I wrote a bit of an illustration of this:

http://www.mindcontrol.org/~hplus/epic/

enum Bool { True, False, FileNotFound };

@hplus0603
So in the article you talk about interpolating between last render and the new update.

Suppose our client's clock looks something like this:

accumulatedTime += time.deltaTime;

if (accumulatedTime ≥ fixedDelta) {

accumulatedTime -= fixedDelta;

simulate();

}

Are you talking about interpolating by just doing:

Alpha = accumulatedTime / fixedDelta; ?

If so, then that's already what I had in mind. It just seems like its still going to seem to teleport if the corrections are too large. I suppose there's not much you can do beyond that.

If you download and run the example, you can see how the extrapolation will “overshoot,” but it will correct smoothly – albeit “smoothly” with a velocity that's higher than a normal player would have. It won't really “teleport,” unless your frame rate is really low or your network is really bad.

enum Bool { True, False, FileNotFound };

Going back to the original post: if you need to ‘predict’ states, you would't also be buffering, because by the time you drain the buffer and render the state you predicted some time ago, you'd have the authoritative data anyway! And thus no need for the prediction.

For me, either you're rendering buffered authoritative states, or you're predicting unauthoritative states, with nothing particularly useful in between.

We had a system on Fall Guys where object positions could be extrapolated, any time that we didn't have (or weren't willing to wait for) sufficient data for interpolation. It's basically the same operation, just going beyond the bounds for which we had authoritative data. If data subsequently came in that showed the extrapolation was wildly incorrect - e.g. something happened on the server to change the direction of travel - then we could blend the position back over the next few frames to make the corrections look smoother. There are various ways to do this, with pros and cons, but one way is to simply commit the ‘wrong prediction’ as if it were an authoritative one and simply start interpolating again from there. This at least gives you visual continuity. It helps if you have a smoother interpolation function than a standard linear one, too.

I also want to add that sometimes a teleport is not necessarily a bad thing. Depending on how your game and physics is set up, some games are going to be more robust when an object teleports than they are if an object moves unpredictably or at too high a velocity. If an object is found to be too far away, just teleport it back. Players understand that lag happens.

This topic is closed to new replies.

Advertisement