Skip to main content
gamedev.net
🔒 Locked

Client synchronisation

Started by dnaxx 4 replies 750+ views
Original Post
dnaxx
dnaxx
Hello, I am writing a java-based multiplayer game where players can move around and play with a ball. The communication between server and clients is done via UDP: first die client registers with the server and then it regulary sends the actions from the player to the server. so the server has all (position) data from all players. now I send the position data from all clients to all clients. but due to some delay sometimes the ball and player positions are not the same on all clients. generally this isn't a problem, but sometimes it leads to irritations. I hope, that you understand what I mean ;). Whats the best approach to synchronize clients to avoid these problems? Thanks,
rip-off
rip-off
do you mean that your client sends data to a server AND to the other clients.

if you haev a server, it is more usual for the individual clients to send the data to the server and pass the reponsiblity onto the server to send the data to the rest of the clients...

that way every one is only communicating with one machine, and your main concern becomes making sure that the clients can deal with out of order packets and packet loss
dnaxx
dnaxx
all clients send their data only to the server and the server distributes all client data to all clients.

I already implemented this and it works.

the data in the server looks like this (client#: xpos, ypos):
client1: 12,12
client2: 13,1
client3: 55,7
ball: 56,7

this data is submitted to all clients.
rip-off
rip-off
Quote:
Original post by dnaxx
now I send the position data from all clients to all clients. but due to some delay sometimes the ball and player positions are not the same on all clients. generally this isn't a problem, but sometimes it leads to irritations.


i misunderstood the first line there...

anyway, remember that if the players arent directly comparingthe two screens together, they wont know that there are slight differences between the different views.

thats the problem with networking, you can't do too much about the delay of client receiving data, apart from trying to cut back on the amount if data you send and maybe client side prediction...

dnaxx
dnaxx
ok. thanks for commenting my problem. i will just finish the game and if it looks too ugly I'll need to implement some prediction algorithm...
ro4tub
ro4tub
yeah,"prediction algorithm" is a good thinking .

u use UDP as the transmission protocol,and if the game is small,i think
u should use the concept 'Host Server' like CS!


A (Client also Server)

B (Client) C(Clinet)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.