Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Turn Based Multiplayer, Client Side Sync or Server Driven commands? Pro&Cons

Discussion in 'Connected Games' started by Concato, Jul 18, 2019.

  1. Concato


    Nov 24, 2015
    Hello everyone,
    I'm making a turn based game and right now i'm approaching to multiplayer side, let's say 1v1 for now because of that i'm here to ask advice in order to make a better decision on what to do since it's basically my first time.
    correct me if i'm saying something wrong please.

    Game is turn based with a customizable team of heroes, and each hero has different abilities, effects and so on etc etc.

    what i thought was this:

    Solution 1 - All the calculations are made on the client side, like: turn speed, attacks, damages, and so on, the only thing that client is sending to server is the ability he chose and the target selected, then server replies with an array of Randoms to actually make the actions for both players trigger the same chances and so on.
    Using the same randoms makes every calculation the same for both clients.

    Pro - Fast, low server cpu usage?
    Cons - easily exploitable, if game asyncs for any reason there is no saved state on server, except for the other player.

    Solution 2 - Client does not calculate anything (except maybe turn meters, and start / end turn buffs damages) but it sends only target and skill selected, then server calculates what the hero does and returns a list of actions with all the events, example attack, damage, add buff, and so on. Client recieves that and basically replicates the animations with just those values that got from the server.
    So basically after every turn both clients should have done the same skill with same effects and they should be in sync with eachother.

    Pro - Less exploitable since its server driven, less async and possibility to resync with server's copy
    Cons - high overload for server? it has to host a copy of every game and calculate every single attack

    if you have any idea or feedback please let me know.
  2. MrsPiggy


    Jun 13, 2018
    You should go with solution #2. Running the logic client side is never correct. Cheating is already a pain in the arse, if you let the client decide what happens in the game you're asking for trouble.
    Also I wouldn't say that this approach is going to overload the server. From your description it mostly sounds like basic arithmetic (calculating attack points, damage, buffs etc...) which is really not a problem for any decent server.

    I have worked for a while with a solution called SmartFoxServer which I'd encourage you to investigate. You can implement your game logic on the server side and make the client as "dumb" as possible, meaning that is only responsible for visual updates and input collection.SmartFox supports all major platforms, it has good documentation with lots of examples and it's an overall solid product:
    You can get the server for free for up 100 CCU, the API for any platform and example packages. I believe it's available on the asset store, so you may search it there as well.
    Last edited: Jul 18, 2019