Advertisement

Instant Moving after Keypress

Started by February 18, 2003 11:50 AM
7 comments, last by LonelyStar 21 years, 11 months ago
Hi Everybody, As far as I know and my Research tells me, Server-Client Games work like this: When the Player presses a key, the Client sends an Message to the Server: KeyPressed. The Server gets this Message, processes it and sends and Message to all Clients: Player does Action The CLients Recieve the Message and do the Action But when I play Counter-Strike and have a ping of more than 300, I press a key and my Character is moving instantly! What is the trick about this? Thanks a lot for helping me understand
The client often (usually - 200 msec is way too long for an application to feel responsive) assumes the server will eventually ok a move and proceeds to depict it immediately, making the user believe it has already happened. The client also often attempts to predict the actions of participants, like "this guy has been running north for 5 seconds - now there''s no update from him these last 500 msec, I''ll just assume he''s still running that way" - when those predictions are wrong, you get warps (characters "teleporting back or away).

(My projects and ramblings...)
Advertisement
Yep. It works because in most cases the move will be ok''ed.

''client-side prediction'' is a good search keyword on this.



----------
Dauntless for President!
zppz.homeip.net <- game dev stuff
Well, ok, the move will be oked. But still, it takes a lot of time until the Server knows about the Move. And Until that time, the Server is not procesing the move. So, by just proceding the Move on the Client side, does the Client not get out of sync with the Server?
The receipt that the move was indeed OK - or the notification that it was illegal and has been discarded - comes along with the updates for all the other entities in the area, when the server next updates (carelessly phrased). With a client that is doing its job well, the user very rarely sees any correction for his own actions, as anything he can do will also be ok with the server - the main exception will be interaction for other characters, since those can be lagged and there''s not a damn thing the client can do about it, except try to predict their actions.

But - whatever the server says is true, the client *must* also take for truth. So if a prediction turns out to be false, the client must warp that character to its true position, and if a client action is discarded by the server, the client must update to take it into account. Failing to do that is the basic recipe for distributed disaster, which is not a pretty thing :-)

(My projects and ramblings...)
Thanks for your anser "Teodric", but I think you did not understand my Problem.
My Problem is, that if the Client processes the Player moves earlier than the Server (which it does if it Processes them Imidatly), it must get out of Sync with the Server, doesn''t it?
Advertisement
Yes the client and the server do get out of sync, but only by a little bit and thats ok. The next update to the client the server sends out will resync everything.

In a client server model the client is always going to be out of sync with the server by a bit, at the minimum it''ll be the time it takes for information to get from the server to the client.

-=[ Megahertz ]=-
-=[Megahertz]=-
Your research found one method of networking -- a very simplified, and seldom used method.

Counter-Strike (well, half-life) uses a relatively simple series of messages, passed between the server and client to keep them in sync. Actual key-presses never travel over the internet, but notifications such as "spawn an entity with these settings here" do.

And as already mentioned, multiple players in a game arent 'perfectly' in sync. If you do an action, you will see its effects before anyone else does. (But that just plain makes sense! )

Google for more info, (I believe there are some good links on Gamedev.net or Flipcode.com too)
- Jacob


[edited by - Kevlar-X on February 19, 2003 5:31:14 PM]
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
Sorry if I was unclear - that was indeed what I tried to answer.

- Yes the client does get momentarily out of sync.
- The client must always update its predictions once the "real" outcome arrives from the server.
- These updates must override any client-side calculations already made.

hope that claifies a bit?

(My projects and ramblings...)

This topic is closed to new replies.

Advertisement