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

Step by step guide for setting up Unity multiplayer?

Discussion in 'Multiplayer' started by rsud, Dec 27, 2014.

  1. rsud

    rsud

    Joined:
    Aug 13, 2010
    Posts:
    89
    Hello,

    While I am a good programmer in c# and have been "playing" with Unity for a while (and got an iPhone game out!) I have no knowledge for setting up (deploy) a multiplayer environment using Unity. I would like to learn but so far I have found a bunch of disparate documentation and nothing that guides a newbie (like me) through the basics.

    The training material I found so far shows coding multiplayer but nothing that spells out the details of the infrastructure that is need and how to deploy a multiplayer game into it.

    Some of this info is not directly Unity related, but needs knowledge of how to setup a server.

    I have a mac mini that runs mac osx and windows 7 professional. I have Unity installed on both side. I have the free version of Unity (with the iPhone license).

    I'd like to learn specifics for the following areas:

    1) what do I need to do to setup a server for multiplayer unity game on my mac mini (either on windows or mac osx)? Do I need to install a web sever? What is available to accomplish this?
    2) What exactly do I need to do in Unity to deploy my game to the server?
    3) What exactly do I need to do in Unity to deploy my client to any PC or mobile device?

    Is there some concise training available that focuses on this setup (paid or free)?

    Would anyone work with me (train me) or walk me through the steps so I can understand the details for this?
     
  2. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    What kind of game do you want to make? Real Time? Turn-based? For some types of games all you need is a program on a server that relays commands to the clients. My game can handle up to 4 players. It is a turn-based game but uses a "real-time" server which means that although the game is played in turns, like chess, all clients have to be connected to the server for the whole duration of the game that is being played. Clients can't disconnect, and come back later to play their turn (that is async turn-based).

    So in a 4-player game, Player1's client sends a move command to the server. (Move Piece 1 to X,Y) The server relays that move command to Player2, Player3, & Player4 clients, each having an exact copy of the game state. Then Player2, Player3, & Player4 clients recieve and act on that command which was sent by Player1's client. That means that Player2, Player3, & Player4 all place a Player 1's Piece 1 at position x,y. Then Player2, Player3, & Player4 handle the side affects of placing that piece. A side effect could be moving or destroying pieces that surround x,y. The clients handle this, not the server. Each client does exactly the same thing. And the results on each client is exactly the same because each client always has an exact and updated copy of the game state.

    And if your game is a very small game for just you and your friends then make your own server. But If your game is meant for the public, rather that having your own server with all the maintenance, keeping it online 24/7, expanding it to meet demand, it is probably better to rent a server. many services have complete solutions. Matchmaking, rooms, turn-based, and real-time services. And some even allow you to buy and download the server software so that you can run it on your own hardware.

    The service I use is Shephertz AppWarp for the mathmaking and game play. And Shephertz App42 for User accounts, registration, etc.

    http://appwarp.shephertz.com
    http://api.shephertz.com

    Their server that you can host yourself is called
    AppWarp S2 On-Premise

    They got fantastic service, and a lot of tutorials, And Unity SDKs.
     
    greenLantern101 likes this.
  3. rsud

    rsud

    Joined:
    Aug 13, 2010
    Posts:
    89
    Hello TokyoDan,

    I would like to host a multi-player real time game.
    So a server that hosts a running game, multiple players can connect and maintain their own avatar.
    All action and interaction would be in real time between the players.

    I expect a master server that maintains the game state and updates the clients (players). The players can connect, establish their avatar (user/password entry), and then interact with other players and game controlled entities in the game. Players can come and go during the runtime of the game.

    I do expect this to be public and plan to get a hosting service and an internet facing server.
    This is the long term plan.

    But, for now, want to set it up on my home network and have myself, kids, friends connect for the initial development period.

    So I want to host this real time game on a server (my mac mini running windows 7 prof or OS X) that other computers / clients can connect to.

    So I believe I need advice from someone that knows how to setup web servers and deploy a unity game on it.

    Any pointers / help really appreciated!

    Thanks!
     
  4. rsud

    rsud

    Joined:
    Aug 13, 2010
    Posts:
    89
    Hello TokyoDan,
    I would like to host a multi-player real time game.
    So a server that hosts a running game, multiple players can connect and maintain their own avatar.
    All action and interaction would be in real time between the players.
    I expect a master server that maintains the game state and updates the clients (players). The players can connect, establish their avatar (user/password entry), and then interact with other players and game controlled entities in the game. Players can come and go during the runtime of the game.
    I do expect this to be public and plan to get a hosting service and an internet facing server.
    This is the long term plan.
    But, for now, want to set it up on my home network and have myself, kids, friends connect for the initial development period.
    So I want to host this real time game on a server (my mac mini running windows 7 prof or OS X) that other computers / clients can connect to.
    So I believe I need advice from someone that knows how to setup web servers and deploy a unity game on it.
    Any pointers / help really appreciated!
    Thanks!
     
  5. drew_s

    drew_s

    Joined:
    Dec 9, 2014
    Posts:
    14
    I would be extremely interested in a tutorial for a turn based game tutorial that is for Unity.

    I have a single player game already written that is turn based that can have 1-4 players on 1 phone right now. It is like a "words with friends" game where the other people can't have a turn until the other people make their turn previously.

    I've been searching for a bit on how to get this into multiplayer but haven't had much luck, so I'm in the market for this as well!
     
  6. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Sorry but I haven't got the time nor do I believe I am qualified to give a detailed tutorial. The best bet would to follow the tutorials on the Shephertz site.
     
  7. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    I posted this also in this thread

    I think when you work with networking, of course look to Unity for advice, but mostly, look to the company that created the networking solution you decide to use, and get a good contact in their support section. After a lot of research I decided to go with Shephertz. One reason was they had a Unity plug-in. Another reason is that they had a lot of info in their forum and a lot of Unity specific tutorials. The reason I stuck with them is they got everything a developer could want when creating an online game -- both gameplay networking, storage, and social. But the main reason I stuck with them is that their service is incomparable. Absolutely the best service I have ever received from any company in any business. I mean personalized, prompt, going-way-out-of-their-way perfect and detailed help. They even built DLLs for me to solve unusual problems. They have been helping me for over a year now and I have yet to pay them because I am a lone indie developer and my game is not published yet. (I doubt this will last). Everything I learned about creating an online multiplayer game, with or without Unity, I learned from the Shephertz website, and their support.
    And although my game is a Unity game. it uses no Unity networking at all. It uses just Shephertz AppWarp and App42.

    If I were you I'd make a simple two-player 'online' game which is a client that has a button and a textbox. When you click or tap the button, it sends a text string message (e.g. MOVETO X,Y) to another instance of your game client. That 2nd instance receives that text string message and displays it in the textbox. Figure out how to get Appwarp hooked up so that their server receives that message from the 1st client and relays to the 2nd client so that the 2nd client can display that message. Just follow the tutorials on AppWarp webpages. You can then see how you could add a game object that responds to that received message. You'll get the idea of how a simple (very very simple) game does one kind of networking. That is basically how my board game works. That's how it places pieces at certain places on the opponents' boards, and that's how it sends chats to the other players.
     
  8. rsud

    rsud

    Joined:
    Aug 13, 2010
    Posts:
    89
    Hello TokyoDan,
    I typed my answer to you before going through the links you provided.
    Site looks great and I'm sure it will meet my needs based on what I have been reading so far.

    Thanks so much for this pointer!
     
  9. waqasKK

    waqasKK

    Joined:
    Nov 18, 2015
    Posts:
    2
    hy i need some help from an expert plz reply me my email address
    k122466@nu.edu.pk
    details about project is discuss on email
     
  10. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    Try Google multiplayer you can find Free Unity plugin & setup tutorial here : Github Link.