Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Converting a game that plays on a single PC to server-based multiplayer

Discussion in 'Multiplayer' started by nhurwitz, Jan 27, 2023.

  1. nhurwitz

    nhurwitz

    Joined:
    Jan 5, 2018
    Posts:
    7
    Hello, I know there's no way of answering this too specifically, but I'm trying to get a sense of the effort involved to convert a multiplayer game developed in Unity to play on a single pc to multiplayer on a server. It's a turn-based game that doesn't require players looking at the same window or information at the same time. The game state is currently being saved each turn so that it can be exited and restarted from where players left off at a later time.

    I appreciate anyone's thoughts on this. Thank you.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    So you have a working singleplayer game, and now you want to port it to be multiplayer?

    How much effort this is depends a lot on how well the code is architected in the first place and whether there was any thought given to adding multiplayer modes later on. It could be as simple as making a few variables network synchronized - plus the usual network setup, host, join, etc stuff. Or it could be a really nasty endeavour where it might even make more sense to rewrite the entire project as a server-client game with singleplayer simply being the host playing alone.

    The fact that you ask this kind of question makes me believe the actual effort will lean towards or even exceed your worst case expectation. ;)
     
  3. nhurwitz

    nhurwitz

    Joined:
    Jan 5, 2018
    Posts:
    7
    Thanks for the reply. I didn't write the code, so it may not be as bad as you're suspecting. And I believe the code is well-structured, although not designed for server play. I would imagine it being turn-based and having the ability to save the game state to reload at a later time would work in its favor.

    And just to be clear on the terms. It's a single-pc game that multiple players can play in a hot-seat fashion. Nothing about the logic of the gameplay itself needs to change.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    That sounds "better" but how that affects the porting effort largely remains guesswork.
    Perhaps the easiest approach here is brute-force: synchronize the end-of-turn data all at once. Hopefully it's not that much data.