client server question

Started by
4 comments, last by hplus0603 9 years, 9 months ago
Greetings,

I am doing research for a project I have a question to see how people would do something.

So my question is let's say I have a orpg game my client moves to xy cord it sends apacket to server client will assume that it can move etc server checks data moves player back if need be now What is the best practice for broadcasting to the other players in the location that a player moved without large amount of lag I see games do this but can't wrap my head around it. Please explain.
Advertisement
The server keeps some information about each connected client. X times a second, the server will iterate over all connected clients, and send them updates for things that have changed that they see. The more frequent X is, the less lag there is. ORPGs can get away with X in 1 .. 5 times a second. FPS games go from 10 on the low end to 120 on the high end, with a happy mean around 30 in many cases.
enum Bool { True, False, FileNotFound };
Basically how it would work would be something like this

Client A moves to x1 y2 sends movement packet
Game server recv packet broadcasts to all clients that client a moved clients then do there thing etc.
You really don't want to broadcast the move command as soon as it comes in, because then you will have N clients broadcasting to N-1 other clients, for N-squared number of packets coming out. You want it to work like this:

Clients send inputs at some interval (client send rate)
Server processes inputs so they affect the world at some period (simulation tick rate)
Periodic timer sends updates about world changing to clients (network tick rate)

The three rates do not need to be the same. It's common that client send and network tick rate is the same. It's common that the simulation tick rate is some integer multiple of the network tick rate.
enum Bool { True, False, FileNotFound };
So it's common that clients are out of sync with each other by a few mms? Should the server send the world update to everyone or just to clients it would effect

So it's common that clients are out of sync with each other by a few mms?


The out-of-sync is typically measured in TIME, not in SPACE. If your physics simulation rate is fixed and everyone gets the same control commands, they will all display the entities in the same locations. However, those that get the commands later, will display those entities in those locations, later.

Should the server send the world update to everyone or just to clients it would effect


For small games, it's easiest to always send all players to all players. For large games, an interest management layer is typically added to send data only for entities that the target client can interact with and should know about.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement