Sign in to follow this  

Server simulating clients and lag

This topic is 2484 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

Reading the valve docs, it appears to me that Client A sends a snapshot to Server, say, every 50 ms.

Server simulates all clients every tick, and every 50 ms, sends client snapshots to all clients.

What I was wondering, if the above is correct, is what does server send to Client B regarding Client A?
Does the server take the snapshot it received from Client A, simulate it for a bit using the keypress information in the snapshot, and send that to client B?

If Client A were to have sent a snapshot with keypress Left and a few ms later press Right, then the simulated position on the Server would be incorrect wouldn't it?
If so would Server tell Client A where Server believes Client A is to correct it?

Also is the interpolation used only on clients, ie, the server doesn't have to apply any interpolation as noone really needs to see what it sees?

Thanks all! Network programming sure is a different beast.

Share this post


Link to post
Share on other sites
[quote name='bobrules' timestamp='1298442517' post='4777855']
If Client A were to have sent a snapshot with keypress Left and a few ms later press Right, then the simulated position on the Server would be incorrect wouldn't it?[/quote]The server is [i]never[/i] incorrect. The clients are [i]almost always[/i] incorrect.
Clients only send inputs to the server. The server sends the game state to clients.[quote]What I was wondering, if the above is correct, is what does server send to Client B regarding Client A?[/quote]Each client receives the full state of every (visible) player, including themselves.
Player state is stuff like position, rotation, velocity, animation, etc...[quote]Does the server take the snapshot it received from Client A, simulate it for a bit using the keypress information in the snapshot, and send that to client B?
If so would Server tell Client A where Server believes Client A is to correct it?[/quote]The snapshots sent from client to server [i]only[/i] contain inputs - the server can't "simulate the snapshots".
All client key-presses are fed into the servers simulation. The state of that simulation is then sent to all clients.
Yes, if the clients local predicted simulation is wrong, the it will be corrected using the server's version.[quote]Also is the interpolation used only on clients, ie, the server doesn't have to apply any interpolation as noone really needs to see what it sees?[/quote]Yes, interpolation is only used on the [i]graphical[/i] representation of things (on the client-side).
The only exception to this is server-side lag compensation, where player positions are interpolated [i]backwards[/i] in time, to guess where the player [i]thought[/i] they were when they fired their gun. That's another whole complex layer on top of the basics though.

Share this post


Link to post
Share on other sites

This topic is 2484 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this