RTS Multiplayer Model

Lately I’ve been trying to develop a RTS Multiplayer based game and I’ve read some stuff about how Age of empires multiplayer was done and some models of mutliplayer game and I’m quite worried if my model will work.

My idea was to have all the players host an instance of the game as client mode and the one hosting run two instances of the game, one as client like the others and one as server.

The server instance would receive all the commands or actions executed by the players and run the simulations (Like pathfinding, moving a unit, making a unit attack) and at the same time tell all the clients the coordinates (the state of the transform component) of all the units at all times, so basically only the server had the authority to move stuff around and the clients would only be able to see where the units are and select them to give them orders which are sent to the server and the server executes them.

At first I thought it would be a good model but then I realized it’s very bandwidth consuming and I’m not sure if it would work. Since it’s a RTS there could be 1000 units moving at the same time, meaning the server would be needing to send the position of 1000 * the amount of clients connected (Maximum 8 players) and the corresponding action they are performing in order to predict the animation. So it would be 1000 Vector3s * 8 times + a int of the action ID * 8, approx 32000 values per frame, meaning if server is running at 90 FPS we would have 2,880,000 values per second. Sounds like a great number to me but assuming we have a 1MBps minimum requirement bandwidth to play the game, would it be way too much data to be sent, or would it work?

1 MBps strikes me as very high. You’ll hit a GB of data in about 20 minutes. My entire monthly bandwidth would be gone after playing you game for 24 hours. (You may laugh, but capped internet is still a reality in many parts of the world.) Even on an unlimited plan my ISP provider would probably throttle speeds.

Ever wonder why Age of Empires had that annoying population limit?

Sending the position every frame is probably not needed for an RTS. You could send a current position and a target position a couple of times a second. Have the individual clients interpolate to figure out what happens in between.

The technique used in most modern RTS is called Fixed Lock Step and sometimes Deterministic Lockstep. It’s a bit harder to do in managed languages such as Mono/C# which Unity uses but can be done. Here’s a link to a tutorial and sample set of code that someone already did in Unity: http://clintonbrennan.com/2013/12/lockstep-implementation-in-unity3d/

If you want a general overview of the history of networking models, this is a good place to start.
http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/

I also recommend the other information here too as it is relavent and gets pretty in depth on the problems associated with both networking and physics… or even worse trying to have networked deterministic physics!