Advertisement
Guest User

Low level networking

a guest
Feb 4th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. Well, basically, what the client sees is a constant blending between his input and the server's authority..
  2.  
  3. First thing I did was give the Server it's own tick SERVERTICK (1/60th sec). This is the important tick. The server will be sending an UPDATE every SERVERTICK.
  4.  
  5. Then, I made the client send it's tick CLIENTTICK tagged with a "Ping" (ex: "PING|30") command and have the server send it back immediately. When it gets on client side, you know that CLIENTTICK current tick - tick attached to the ping command = how long it took to get the message to and from. Keep a track of this variable and constantly average it out -- ROUNDTICK
  6.  
  7. So now the fun part: When you send input to the server, you want to predict where the player is going to be when it reaches the server to make up time to transport. So you take the input, run it through it's commands ROUNDTICK amount of times, and send it to the server. You can attach (SERVERTICK + ROUNDTICK) so the server knows what frame the information represents (lets say you predict for T32 but the server's only at T29, you can wait 3 ticks to send the information back)
  8.  
  9. On client side, go ahead move the player towards where the input says, and then when you get an update from the server, it's going to hold hold information with SERVERTICK, so the trick is that, that SERVERTICk was ROUNDTICK/2 ticks ago, so you take the input and multiplay it by ROUNDTICK/2 ticks, and then you check how close that information is to the information the player has on the screen, and if it seems off then you interpolate between the player's screen and the what the server says
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement