• Advertisement
Sign in to follow this  

Player prediction worth it?

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on the physics code for my engine. I have the physics working nicely on the server-side, and now it's time to decide what the client needs to do. I had the client-side prediction working prior to switching physics engines, but it's complicated and has problems with other moving objects in the world. The way I did it was every time a frame arrives from the server, I would update the positions of all the objects in the universe and run a local version of the physics on the client for the duration of the ping replaying player commands. (Valve does something similar. And yes, I grossly over simplified what's going on.) This method has 3 draw-backs: It's a pain to manage; It doesn't like objects that move/start/stop randomly; It eats time on the client that could be spent rendering. So now I have a decision to make. Do I update the client prediction to work with the new physics engine or go old school and recognize connection speeds are a lot better than they used to be. I'm curious what the opinions are on this.

Share this post


Link to post
Share on other sites
Advertisement
It's not just worth it, it is absolutely mandatory.

You need interpolation and extrapolation/prediction to cope with lag, which is unavoidable. First of all, interactivity suffers if you don't do any prediction (even for excellent connections), which quickly becomes an issue.
Second, the game will appear very jerky and unnatural for players having less than optimal routes.

A round trip time upwards of 100ms is not unusual at all on the internet, and this is not going to change, regardless of technical advancements.
If you add a little time for server processing too, you can easily get into a range that is disturbing.

Share this post


Link to post
Share on other sites
I know a crisp player response is very desirable. But look at the penalty associated with client-side prediction.

Let's say that the player has a ping of 100ms and that the physics is running a 10ms time step. The delay between the server and client is 50ms (half the total ping time) which means the player is running 5 physics frames behind. This means that for every network frame received, the client must run 5 physics frames into the future to predict the server's current solution. In this example, the client is having to do 5 times the physics calculations of the server. You can cheat by moving all the entities linearly based on last known position and velocity and running just one frame, but this defeats the physics ability to model interaction between entities. A the very least, it causes jumps between the server's and the client's idea of where everything is.

In short, client prediction is a hog for client CPU resources which is already burdened by the rendering demands. The problem is magnified by fast moving objects or objects that bounce around.

Share this post


Link to post
Share on other sites
Well, thing is that you can't rely that something happens within 100ms.

A considerable number of your players will have a distance like the atlantic ocean between themselves and the server, which alone adds 100ms due to the speed of light. This doesn't take into account any routers, just the speed of light.

You have to run the game on the server side at some time step too, so the server will queue all player commands during a time interval and every so and so often decide what happened. Let's assume you have a 100ms time step here, which is acceptable for many types of game. So we're already talking of up to 200ms.

Let's say your toon slings a pebble at a rabbit. With client-side prediction, the toon will start slinging the moment you hit the button. It will either miss or hit when the server response comes. Immersion is good.
Without client-side prediction, you hit the button, and nothing happens. Your toon is standing there for 0.2 seconds like an idiot, and you wonder what's happening. This is very perceivable, and very disturbing.
Make it only a little longer, and you will see players hitting the button again because they got the impression it did not work. And of course, then they'll be upset because it wasted two sling stones. This sucks big time.

The same is true for many other situations. Prediction and interpolation is utterly necessary.

Share this post


Link to post
Share on other sites
Well, I'm old school, meaning I played quake1 with 500ms pings and no prediction. Lag was a way of life and you just learned to play with it. When I got ISDN, my pings dropped to 100ms and I thought I was god. :)

My concern is that the physics is going to kill the frame rate which is why I'm giving it a lot of consideration.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement