   Handling delays and calculating objects position in network
  I am thinking a bit on how to handle delays over network.Player 2 at time x is at position 10,10 and the server sneds a message to player one about this. When the message has arrive to player one, player two will no longer be at that position. An idea for the solution was to let the server ping the players every second, and use this time to calculate where the player should be when the message arrives to player one.But the ping time can vary alot, if the ping time a second ago when the ping was sent was 20 ms, and it for some reason takes 3000 ms for the message to travel, the ping time will be completely off. It is impossible to know beforehand how long time the next message will take to send.Any ideas on how to solve this?   
  I think the solution to this is in two parts:1. You come up with a system where the client maintains an approximated subset of the state of the server. I say approximated because a client's state is generally out of date with respect to the server.If you consider the server to be authoritative, then the client accepts corrections to its state subset from the server (e.g. updates about the positions of other players). The client can also modify the server's state in specific ways - for example "I am moving backwards" and "I have fired a missile".I believe this is more or less how Unreal Tournament's networking code works (I don't really know about the latest Unreal Engine though). I don't think it particularly bothers trying to compensate for network delays, however - players with high pings have to lead targets considerably, which implies that there isn't much of an attempt (if anything) to compensate for delays.Also, since you're wanting to handle delays over a network, I assume you're not going to operate over a LAN, so you'll probably also need to handle packet loss.2. You could use a method similar to Network Time Protocol (NTP) to enable the clients and the server to "synchronize their watches". This should also enable you to figure out the mean delay from client to server and server to client, and maybe also other things like the variance of the delays.By adding timestamps (accurate to a millisecond or so) to messages you could have the clients and maybe the server attempt to compensate for network delays, but I think it won't work well when a client's ping gets too high. If the ping between a client and the server is too large, then the server will end up disagreeing with a client about what just happened. That's pretty much guaranteed to lead to players having "WTF?" moments.   ;  This question gets asked every 3 days in this forum. What, in particular, is wrong with the Forum FAQ that it doesn't cut down on the asking -- or answers don't reference it?I'm looking for suggestions on how to improve it.;Quote:Original post by hplus0603This question gets asked every 3 days in this forum. What, in particular, is wrong with the Forum FAQ that it doesn't cut down on the asking -- or answers don't reference it?I'm looking for suggestions on how to improve it.The problem is the distinct lack of multi-player and MMO concept tutorials in general.Documentation is either production code, or academic work, with little in between, making it hard to find starting points. Unlike various 3D and 2D concepts, which have been discussed over and over during the years, networking is quite elusive, especially for someone starting from scratch.Ironically, neither of the concepts is that hard, but it's completely separate from everything else, and requires different train of thought.;  hplus0603, I was going to say: A bold sticky announcement: READ THE DAMN FAQ FIRST! But, alas even that probably won't help.(And it doesn't help, because its already there!)   ;Quote:Original post by hplus0603This question gets asked every 3 days in this forum. What, in particular, is wrong with the Forum FAQ that it doesn't cut down on the asking -- or answers don't reference it?I'm looking for suggestions on how to improve it.I think the problem is 'questions' such as the following:"How do I interpolate my character based on server lag, and still keep it in sync with the server?"and"I'm using client prediction by simulating objects client-side, but update the entity positions to the "true" positions when I receive updates from the server. This causes snapping in the position on-screen. How can I hide this snapping?"...seem to be overly specific and designed to help those who understand the problem but not the solution. They assume you already know that you need interpolation, synchronisation, client prediction, etc. Yet these things are probably not obvious to everybody. There's nothing much giving a basic low level understanding of all the issues involved.   ;  I think we need a 'I want to start a MMORPG' entry in the FAQ. In any case, compared to the other sections, we're missing on basic article, examples and tutorials.   ;Quote:I think we need a 'I want to start a MMORPG' entry in the FAQ.We do -- it's question 0 :-)On the n00b intro pointers -- are there any good resources? Most of the ones I've looked at have been pretty terrible. There is a pointer to Beej's, but that only deals with connectivity, not with what to do with the connection once it's there.   ;  I have to admit, I was tempted to answer with either, "No, no one else has a problem with this, must be something in your code" or "Sure, it's easy, just set the SOL_REALTIME socket option".;  Beej's stuff is great. The next step is the hardest, it kind of strides the network programming (sockets, NAT, ...), and the multiplayer programming. TO create a tutorial on how to design a multiplayer action game could stretch for a while. I suppose a network pong would be a start as far as network game tutorials are concerned.   