multiplayer rts --> Arrays

hi everybody,

i’m thinking/planning about making a multiplayer rts.
My idea of the networking part is to transmit only the issued commands to the unity over the network.
So, no positional updates, no animation updates, only, if a player orders a unit to get to point x,
then a single command would be send over network like
IssueMoveCommand (int unityID, int CommandId, Vector3 position)
for example.

That way, i could safe tons of unnecessary network commands. Only important things like the dead of a unit would
be send over net to ensure that the game doesn’t run completeley asynchronous.

My questions are now:

  1. Does that sounds like a good idea, or rather stupid ?
  2. If the player has selected a group of units via box selection, for example, unit number 50 till unit number 100,
    is there a way to submit an array of unit id’s rather than calling the same network send method 50 times, one for each unit ?

I’m just in the planning at the moment, to avoid having to rebuild half of my game later on when i see that the basic idea doesn’t works.

thanks for your replies in advance :slight_smile:

It’s a great idea - but it is extremely hard to pull off. For a whole bunch of reasons, the code and variables will normally diverge leaving you with entirely different games, and writing a engine that doesn’t do this is not trivial.

Most games tend start with this concept, and rely on ‘snapshots’ to be sent every so often (e.g every second) to correct any mistakes early on.

  1. yes - it simply depends on how you write your network code.

thanks for your quick reply …

so i would iterate through all units at the server, and send whole updates for let’s say 2 unity per frame, to force synchron gameplay.

But number 2 still gives me a hard time …

could you give me an example of how i would send an array of variable size over net ?
NetworkView’s send function only supports a very limited amount of variable Types, for example string, int, vector3 …
but they didn’t mention arrays.
So if the player has selected 5 units, it would need to submit the id’s of this 5 units, and if he had selected 20, then 20 id’s would need to be transmitted.
So i cannot use a fixed function.

Greetings =)

I’d go with strings… you’d have to use some sort of a delimiter and you could easily get the needed ids, positions etc on the client.

reculum,

FYI - ElectroServer comes with a RTS Unity game example (and source code). It is on the simpler side, but you might find it useful. When installing ElectroServer you have the choice to include the game examples.

This is what Age of Empiers/Kings did for the multiplayer and they got recorded games free (With a little work) with it.

Article: 1500 Archers on a 28.8k 1500 Archers on a 28.8: Network Programming in Age of Empires and Beyond

Key part would be the FixedNetworkUpdate Loop to keep unit commands sent out at the same time and a RandomNumber gen thats synced for all players.

Nice thing about this is the low bandwith needed since your only sending commands that happen 3 or 4 times a sec at most.

What is the “FixedNetworkUpdate” loop that you speak of?

Thanks.

Its talked about in the link I posted.

It just saves any commands sent over the network and delivers them all at the same time step so that all the clients have the actions executed at the same time. Gives a small delay to the orders the players issue but keeps them all synced.

Loop as in you have your:
Main loop (Unitys Update() function), Called Once a Frame.
Physics loop (Unitys FixedUpdate() function), Called Once every Physics Timestep
Network loop

Got that. I have actually read that in article about a dozen or so times in the past. You must be talking about the queued execution of commands.

I thought that you may have been talking about some function in Unity that handles that automatically.

I am working on an RTS myself, and the biggest thing I dont understand is the synching of the timing. I am thinking of using something like Electroserver to handle the command grunt work, and playing out the the commands on each computer (as illustrated in 1500 archers).

Thanks for the help.

BTW, you’re stuff looks nice on your website.