Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I get started with online multiplayer? (in Unity 2019.3)

Discussion in 'Getting Started' started by graybear209, Mar 14, 2020.

  1. graybear209

    graybear209

    Joined:
    Nov 18, 2018
    Posts:
    11
    I'm building a simple online multiplayer strategy game as a hobby project and I'm trying to figure out how to get started building the online multiplayer component.

    Unless I'm missing something, all the tutorials I've found talk about the deprecated UNet APIs. And even from digging through the Unity official blog posts and website about the "new" Unity online multiplayer system -- everything seems to link back to the old deprecated documentation. And I cannot seem to access the APIs described in this documentation as I assume they've been removed from the build of unity I'm using (2019.3).

    Are there any tutorials or documentation on using the new Unity multiplayer system?

    Is the new multiplayer system accessible (and cheap?!) for a 1 person hobby project where I wouldn't ever really expect more than 5 concurrent players?

    Are there other libraries I should be using instead?

    Thanks!
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,842
    That'll depend in part on what sort of networking needs you have. Is this a turn-based strategy game, or real-time?
     
  3. graybear209

    graybear209

    Joined:
    Nov 18, 2018
    Posts:
    11
    Simultaneous turn based.

    The game loop is like:
    1) All players plan out the actions their game pieces will take next turn simultaneously, and submit (during lets say a 10 second window)
    2) Actions taken by all players are simulated on the game-board simultaneously, updating the state of the game
    ...then back to step 1
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,842
    OK. So are sending batches of data, rather than continuous streams like in a real-time game.

    So one way to do that would be with the UnityWebRequest APIs, and a simple REST server that basically just hangs onto the latest data from each player and returns that upon request. You could write that server in PHP, for example.
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    No, and for now you can just ignore everything they say about it. Currently all it is is the FPS Sample's networking system.

    My typical recommendation is Photon thanks to it having a one-time tier that is excellent for hobbiysts, and if for some reason a game takes off it can scale up to large numbers of players with no real effort on the developer.

    That said what @JoeStrout mentioned would work too. There are tons of tutorials available for his approach too. Below is one based around JavaScript. You will need a virtual private server to run the server code but you can rent them for around $5/mo from companies like Digital Ocean.

    https://dev.to/cemuka/making-a-rest-service-using-node-and-express-to-use-with-unity-part-1-321n
     
    Last edited: Mar 15, 2020
    JoeStrout likes this.