• Advertisement
Sign in to follow this  

Understanding network code

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

I am trying to understand how a server communicates properly with the clients

 

Player1 Moves which means his new position needs to be updated on the server

Player2 Moves which means his new position needs to be updated on the server

Player1 screen needs to see the updated position of Player 2

Player2 screen needs to see the updated positon of player 1

 

My question is how do you make the server only send the clients that need updating and not its self,this is going to be become more trickyer with more clients so i am unsure how to implement updating of the clients screen correctly,what i mean is like

 

5 Players on the server

Player1 Moves

Player2 to 5 needs to see Player1 updated position

Player3 Moves

Player1,2,4,5 needs to see Players3 updated position

 

see what i am getting at?

 

 

Share this post


Link to post
Share on other sites
Advertisement

Basic idea:

 

Player 1 moves, and sends its own updated position to server.

Server sends Player 1's updated position to Players 2,3,4 and 5.

 

And then there is a whole world of magic like

"lag compensation", "cheating prevention", "bandwidth management", "dynamic game entry/leave", etc...

Edited by Nikopol_AU

Share this post


Link to post
Share on other sites

The typical way this is solved:

 

1) Set a fixed send rate -- say, 10 times a second, or 20 times a second

2) Each time the send time comes up, iterate through all the players

3) For each player, get the data they need to receive, and send it in one packet

 

Note that, on a bigger map, you may not want to send all the data for all the players; you may want to do interest management and only send data about players that can be seen, for example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement