Client <-> server collision problem

Started by
27 comments, last by Herr_O 22 years ago
You need to correct for the latency between the client and server. You''ll need a more accurate timmer algorithim, such as NTP. Look on www.codewhore.com for all the informaiton you''ll need.

Good Luck

-ddn
Advertisement
One thing I always do when writing any networking app is to have a unified time system that is shared between all machines. This system is quite easy to set up because each machine can send a series of pings to find out the latency over a connection.
Once you have machines that are able to report the same synchronised time, down to a couple of milliseconds, then lag compensation becomes a lot easier as you know who sent messages when.


Martin Piper
Argonaut Games plc.


[edited by - fnagaton on April 21, 2002 10:43:07 AM]
Martin Piper
NTP seems to be a little bit overkill for my app.

Dean Harding, I don''t move the player until I get an answer from the server.. so I shouldn''t have to account for that delay.

I''ve also tried interpolating the client side between the servers true positions and the clients predicted positions, but I couldn''t make it work. But this shouldn''t even be acquired since the latency on the network is only about 5-15ms. I''m considering going back to my old simple network that the clients send positions to the server.. It''s stupid but it looks alot better, no jumps or jerky movement. If I go back to the old routine i''ll add a server check when it recieves the positions and see if they are correct to prevent cheating.

-----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
_____________________________
www.OddGames.comwww.OddGames.com/daniel
Hmm I just had a thought. Are you using a TCP or UDP connection?
My thinking, if you are using TCP then you may be getting all of your packets coalesced which would produce an effect that looks like jerky movement.
It might not be this at all but without looking at all of the code I can't really help more.


[edited by - fnagaton on April 22, 2002 5:08:27 AM]
Martin Piper
Im using dplay (doh) both guaranteed messages and non gauaranteed, mostly non guaranteed.
_____________________________
www.OddGames.comwww.OddGames.com/daniel
Are you using separate frame loops for server and client? I mean server run at a FPS and client at another FPS or the clients wait each frame for a server position/speed update message ?
If each one is independent, is the client able to interpolate pos/speed between frames when messages are not arriving from server ?

Pet.
Are you using separate frame loops for server and client?
I mean server run at a FPS and client at another FPS or the clients wait each frame for a server position/speed update message ?


Nope


If each one is independent, is the client able to interpolate pos/speed between frames when messages are not arriving from server ?

I tried this but could not get it to work. I first got the vector between the servers true position and the clients predicted, then I just cut it up to a few segments.. say 5 then I used these segments (if there were any) instead of my ordinary dynamic method. Like this:

pos+=seg#0..4;

when all segments where added to the position I just continued using the dynamic method. So the interpolation was not a fancy spline or anything But it didn't make such good results anyway so I've gone back to my old network routines (read prev. posts). Now it works fairly well.. so I'm not changing anything *hehe* maybe just a server check to see if clients make abnormal moves and send a correction only then. (ugh)

[edited by - Herr_O on April 24, 2002 1:20:35 PM]
_____________________________
www.OddGames.comwww.OddGames.com/daniel
Strange...because even if I use no client prediction everything works very nice: the client sends only input state change (not every frame it says what the input is, but only when player input change) and the server runs the phisics and send back pos and speed. The client is about 50FPS and server about 30FPS and I have a very smooth animation. What is your ping time between server and client? Maybe if the server is in a separate thread you don''t give it time to do the loop smoothlly ( it is the server running at a decent frame rate? )

Pet.

PS: Anyway, if your network layer works fine with your method it''s all ok. Use whatever method to reach your goal (ex.develop multiplayer game ).
It''s just a small network between my two computers via a router. I get a ping around 15-20. One computer is a bit older, around 30 fps.. the other one has around 60-100fps. I may give the network another shot when the game is completed. anyway, thanks alot!

-----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
_____________________________
www.OddGames.comwww.OddGames.com/daniel

This topic is closed to new replies.

Advertisement