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.
    Dismiss Notice
  2. Dismiss Notice

NOOB QUESTION: How to make multiplayer game

Discussion in 'Multiplayer' started by x10z, Dec 17, 2009.

  1. x10z

    x10z

    Joined:
    Aug 18, 2009
    Posts:
    54
    Well guys, I would really appreciate if you could guide me here.

    I guess have I have a good coding background, I've been able to make every single thing I wanted with unity so far... but when it comes to Online Multiplayer, server-side, and everything that's related, I'm a total NOOB! 8)

    Well, I've been making a turn based multiplayer game for the iphone , I've made A.I. for it , I've made it playable for two players on the same device, and everything... now it's time to get the online multiplayer working :cry:

    What do I need ? Where should I start ? I've read something about smartfox or something like that but I have no idea what it does other than the fact that it is an API that works with unity.

    So what do I need ? Take me as a REALLY IGNORANT person here, because that's pretty much what I am when it comes to multiplayer.

    Help me PLEASE :D
     
  2. Jacob-Williams

    Jacob-Williams

    Joined:
    Jan 30, 2009
    Posts:
    267
    Leepo, one of the community members, has posted an incredible networking tutorial. This should be more than enough to get you started. You can find it here.
     
  3. x10z

    x10z

    Joined:
    Aug 18, 2009
    Posts:
    54
    Thanks a lot man!! Very good! But I still have a problem, maybe the biggest doubt out of them all ... what do I need in terms of server... I want a master server where multiple clients connect and host games and choose where to join and all that kinda stuff ... I need a server.... like a webpage.... that hosts that ... right ? Im lost please help me here lol
     
  4. Dano

    Dano

    Joined:
    Nov 7, 2009
    Posts:
    39
    I've been looking for help/answers in this area as well, it seems that the forums are not very active in this area...
     
  5. Tempest

    Tempest

    Joined:
    Dec 10, 2008
    Posts:
    1,286
    There are two types of hosts.

    A dedicated host means there is a server which controls all game logic. The clients connect to the host to play. This is how MMOs work. The game logic of World of Warcraft is never installed on the client's computer, simply the client application for viewing what the server tells the client to show.

    A non-dedicated host is a host that does not exist until a player (client) hosts it. That Client is not only a player, but also the host. This is how LAN games work (Starcraft multiplayer, Counterstrike LAN, for example). One of the clients is the host and all other clients send/receive from the host.

    Both of these solutions are legitimate and perfectly capable of delivering a multiplayer experience. What you need to determine is the exact multiplaying/networking features you are requiring for your game. If you have a match game, like Checkers/Chess/Counter-Strike/etc, then the non-dedicated host would be appropriate. One of the players is the host, and their computer does all the game logic calculations.

    Keep in mind there is always a risk of hacking/cheating when you put the game logic components on someone's computer, but such precautions must be taken even with a client-only application.

    In regards to the MasterServer, You will need a match-making system. The Unity Networking Demo has this component already completed (with communication with the Unity MasterServer). You can point that code to your own MasterServer to have your application display the available games.

    The MasterServer is like an old-time telephone switchboard. It doesn't host games. It just connects clients. A client says "I'm hosting a game, this is my IP number." The MasterServer displays it for all other clients. When a client joins, they say "Okay, I want to join that game. Give me the IP of the game, and give the game's host my IP number."

    That's all the MasterServer does. I've not dealt with installing my own MasterServer, but I imagine you would need a web hosting package with permission to run your own processes. This is typically NOT part of a low price/cheap web hosting package. You aren't going to find your solution in a hosting package which costs only $3-5 a month. You're probably going to need to pay more for the administrative rights to run the MasterServer on your hosting account. You don't need a webpage, the match-making is all displayed through your Unity application.

    Returning to a dedicated host, I would recommend you get a book about general multiplayer networking. It's a very vast and complicated beast. I don't know if Unity can run in headless mode (no graphics, just game logic), but that's essentially what you would want. A process on the server which dealt with input from clients and game logic.

    The reason why there seems not to be very much information on this subject is because there is SOO much information on this subject. They may not answer your specific questions, but that's because the entire field of networking is very, very huge. SmartFox, Photon, RakNet, your own homebrew solution, etc. What are you looking for, world persistence, leaderboards, etc. There is a lot of information out there, and you'd need to commit several weeks to figuring this out.

    Networking isn't something you can really do half-way. Being able to network two computers together is generally easily, but without security precautions, the game is hacked and compromised. I'm not trying to be pessimistic, but it's a very big beast to tackle.
     
    daoth-gear, Ekou95 and DarkPaladin like this.
  6. athanazio

    athanazio

    Joined:
    Nov 10, 2009
    Posts:
    26
    x10z, here are my 2 cents.

    #1 be ready to pay for a hosting system, I use dreamhost private servers and is working fine for me.

    #2 in order to have your logic at the server you will need a piece of software that runs on the server and respond your network calls, so anytime an event happens on the client side you send to the server, and after that the server will propagate this to the clients.

    #3 there are some products ready to be used for Unity, read something about it here in the forum http://www.electrotank.com/es5.html and http://www.smartfoxserver.com/

    #4 there is option to develop this from scratch also, In my case I'm building the server in Java and probably will migrate to use Netty or Mina

    that's it have fun !
     
  7. Agent-6141

    Agent-6141

    Joined:
    Mar 17, 2013
    Posts:
    3
    when it say 50 CCU does that mean that 50 users can be on at once?
     
  8. playasec

    playasec

    Joined:
    Apr 5, 2013
    Posts:
    1
  9. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    The kid asks for How To, and people give Info? ok to learn MP Network, learn the basics of Hosting, such as:

    var useNat = !Network.HavePublicAddress();
    Network.InitializeServer(32, PortNumber, useNat);

    then the joining part

    Network.Connect(IpNumber, PortNumber);

    then Instantiation and destroying of the players

    Network.Instantiate();
    Network.Destroy();

    But to create a player

    function OnPlayerConnected()
    function OnPlayerDisconnected()
    function OnConnectedToServer()
    function OnDisconnectedFromServer()

    and some enhancements

    function OnServerInitialized()
    function NetworkInstantiate()

    to make server use with MasterServer add this after Network.InitializeServer();

    MasterServer.RegisterHost(GameMode, GameName, GameComment);

    and to stop host

    MasterServer.UnregisterHost();
    Network.CloseConnection();
    Network.Disconnect();

    and some variables for various uses:

    isMine
    isClient
    isServer
     
    ITEAnonymous likes this.
  10. Xsnip3rX

    Xsnip3rX

    Joined:
    Aug 29, 2009
    Posts:
    197
    Thanks for steering the OP in the right direction, i really wish i could give you karma, cookies, or rep, sorry that i can't.
     
  11. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    what OP?
     
  12. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    what OP? thanks btw, hope it helped :]
     
  13. varNinja

    varNinja

    Joined:
    Apr 5, 2013
    Posts:
    1
    *Original Poster

    Also, thanks for the info as well!
     
  14. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    You were zero help. why? This thread is close to 5 years old. OP hasn't even been online in the last 6 months.

    ppl that necro bump anything over 4 years old should get insta-banned.
     
  15. dundee

    dundee

    Joined:
    Nov 18, 2013
    Posts:
    1
    You were the one with zero help, coming here only to "ban" people. There some people not directly involved here that might be helped by DryTear's answer, but yours?

    This post isn't of any help either. But thanks to DryTear
     
    aashwiin_8 likes this.
  16. nastasache

    nastasache

    Joined:
    Jan 2, 2012
    Posts:
    74
    Hi x10z,
    You can read this documentation (even if is not about turn-based) also, to become a bit more familiar with how a multiplayer it's working and how to organize the development.
     
  17. J0ose2005

    J0ose2005

    Joined:
    Dec 29, 2020
    Posts:
    1
    hey, so im using the 2019.4.16f1 version, do these instructions still work?