Darthg8r
Darthg8r

Reputation: 12675

RTS Game Protocol

I've been thinking about a multi player RTS game. The part that I can't seem to get around is keeping unit movement synced. If I move unit A to spot XY, I have to communicate that back to server that relays to the other client.

I'm curious what the communications would look like. Would you just communicate to the server that I'm moving unit A to XY from JZ? Maybe you need to communicate movement coord by coord instead? What's the most efficient methodology to communicate movement of units from one client to the other?

Upvotes: 3

Views: 900

Answers (2)

Thomas Russell
Thomas Russell

Reputation: 5980

I assume you're intending to use the Client-Server networking paradigm? In which case you cannot trust the clients to handle the actual positioning of units, you must delegate that task to the server. You then take the command list from each client per-tick, and compute the movement of each unit, once this has been completed, next tick you relay the position of each unit relevant to each client (either on a whole-map basis, or per-view basis), and start the process again.

If you're only interested in a Peer-to-Peer paradigm, the process is somewhat simpler, as you can either use a circle chain, in which case each client is receiving from one client only and sending to one client only, which can be visualized as a circle of clients each sending and receiving, or a (highly-inefficient) system whereby the client sends the position of his units to each other client, and receives the position of the other's units from every other client.

Personally, I believe the Client-Server paradigm will be the better option, as you remove the effects of cumulative latency, and the issue of a rogue client.

Good luck with your project! :)

Upvotes: 4

Dan D.
Dan D.

Reputation: 74645

i'd think that you'd tell the server to move unit A to spot XY and it would tell all the clients the current location of the unit (if they can see that unit) as it moves at each time step. this basically puts the path finding and battle processing on the server.

Upvotes: 0

Related Questions