Search Unity

[HELP] Need advice on how to structure my RTS Multiplayer Game

Discussion in 'Multiplayer' started by Chapi, Sep 21, 2014.

  1. Chapi

    Chapi

    Joined:
    Aug 27, 2013
    Posts:
    13
    Hello, couple days ago I've started working on a real time strategy (Age of empires style) multiplayer based game (Meaning no AI for the time) and I've reached a point that I'm unsure how to follow working. So far I've coded the basic stuff, like camera movement, selecting units and giving orders to the units, but all of this is multiplayer independent, meaning I haven't coded a single line considering multiplayer situations.

    I'm not sure if what I've done so far can work as it is, or how should I change it, I'm trying to figure out a summary on how the structure should work.

    I've read a little about multiplayer and found that there are some assets in the asset store like photon unity networking which should provide a base to work on networking, but I have no idea how this works yet.

    So the thing I'm asking is someone to guide me and tell me how to follow developing my game, stuff like:
    -Should I have a master server which all clients connects to?
    Should that server transfer information to the other clients or keep track of stuff like units position, what team they are on, etc

    -Or should I let one of the clients in the match be the server? In which case it will be the one storing all the information, should this be done as a separate instance of the game? Meaning the client hosting will still be a client that host the server separately acting like a master server

    -Very important, should I figure out myself how to code the networking all along or should I use something like photon unity networking?

    -UDP or TCP?

    Sorry for the long ass thread but I'm having a crisis here lol
     
  2. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    How secure do you want it to be? How many players do you need to support? How many players per game instance? Do you know this or are you looking for advice in these areas as well?
     
    Chapi likes this.
  3. Chapi

    Chapi

    Joined:
    Aug 27, 2013
    Posts:
    13
    Hey, since I made this question I started with networking on my game and stuff but later today I realized that my idea of having a authoritative server which controls all the simulations and sends the position of all the units in the game to the players as fast as possible might not be possible due to the amount of bandwidth required for this.

    I had thought of a security where only the server would be able to actually cheat since everything would be server sided, about players, 8 per game match and possibly 200-300 units per player so max 2400 units per match, which is alot and I don't know if it would be possible.

    What do you think of server siding everything and sending units position at all times through the players?
     
  4. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,124
    The age of empire game did it with a deterministic simulation and only sending commands between different simulations. You can either do it that way which might mean that you can not use many unity systems like path finding in your game and should code your own deterministic one.
    http://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php

    This is fairly old and new techniques might have been used in recent games and to know that you should take a look at GDC talks and other topics about the subject on the net.

    If you don't want to have a deterministic game then at least your entities should be coded in a way that with 1 updates per second they can work. You have more bandwidth compared to the AOE guys at the time but still not enough to send position and rotation of 1600 units too many times per second.
    position=3*4=12
    rotation 4 (y only) so
    16 bytes per unit, even if you make it 8 with compression and usage of int values and limiting your game, still it's too much, 1000 units*10=about 9kb and 10 times per second would mean a lot (about 90kb) and this is only for psotion and movement and you'll need a little more about 20% for other events and stuff.

    Going in the lock step and deterministic model is what I can see as the right way however I never coded such a game so am not talking from experience.