Search Unity

Multiplayer FAQ tentative

Discussion in 'Multiplayer' started by Vincent-GR, Jan 10, 2009.

  1. Vincent-GR

    Vincent-GR

    Joined:
    Jan 10, 2009
    Posts:
    2
    Hi people,

    I am quite new to Unity and I am trying to figure out all the steps needed to build MMO games with Unity. I have not yet fully grasped all concepts of Unity as a game server, but reading the forum I can see there is a lot to do (which I am willing to, anyway :) ).

    So I'de like to write a step-by-step FAQ to explain how to integrate Unity with custom-made servers (for example to manage buddy systems, games instanciation, etc). Pointers to existing forum messages or documents would be highly appreciated.

    I guess the first step is choosing the technology for your network - I've seen RakNET, SmartFoxServer, NetDog are available options. :
    - http://forum.unity3d.com/viewtopic.php?t=10123
    - http://forum.unity3d.com/viewtopic.php?t=14916
    - http://forum.unity3d.com/viewtopic.php?t=14631

    Then I have the following questions :
    1. What do I need to do to integrate my own, hand-written server with Unity ?
    2. Do I have to write yellow pages system, and how do I integrate Unity with it ?
    3. How do I make UNity clients communicate with my own servers ? Do I need to respect a given protocol ?
    4. Is it possible to add network events in GameObjects that would be triggered by my own server ?
    5. How exactly is built a Unity game server from all the RPC scripts I can write in the Unity editor ?
    6. How do I make a Unity server talk with a database ?

    I guess there are more questions. ANybody wanting to collaborate to this FAQ, please contact me in private and I'll edit this post.

    Thanks !
     
  2. LDiederich

    LDiederich

    Joined:
    Jan 5, 2009
    Posts:
    15
    Hi Vincent,

    you have more than 3 options to get your game multiplayer ready.

    You can use Lidgren Network (c# udp network dll) and the Java server from Projekt Darkstar too.


    Lidgren
    With this dll you can write your own dedicated network server or a peer-to-peer solution. But if you would write a large scale multiplayer game with 2000+ users and different server nodes, you must put lot of work in it.


    Projekt Darkstar
    Currently only tcp (like SmartFox), it's a open source project from Sun Micro Systems. They are planning the largest multiplayer server architecture with thousends of server nodes.

    c# client dll for Project Darkstar
     
  3. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    For SmartFoxServer I am currently working on writing+porting some of the Flash tutorials on the SFS documentation page to Unity.

    Also keep an eye on the Unity Developer Magazine that will feature 3 articles yet (not counting the one in the last issue) including a complete game with lobby - source code included.

    That will save you the work for SFS at least. Cannot comment on the other options, as I havent used those. So dont know how much Unity documentation exists there.
     
  4. Vincent-GR

    Vincent-GR

    Joined:
    Jan 10, 2009
    Posts:
    2
    Hi thank you for your answers,

    The question to which I find no answer at present is: 1. how do I make a game server with Unit, and 2. how do I interface with Unity servers (what API do I have to implement) ?

    To the first question, my understanding so far is that game servers are deployed as game clients, running all the RPC scripts. But where do I write all the initialization code, communication establishing, etc. ? How do I build deploy my server ?

    To the second question, I have no answer at present. Do I have to support .NET remoting protocol ? Do I need to re-implement all Unity events, but then how do I map them ?

    LDiederich I have seen you post on the SFS port. Could you write down some basic tips on what is needed to make such a port ? The Darkstart option seems appealing to me, so I will perhaps study the option of writing a port.
     
  5. tigeba

    tigeba

    Joined:
    Sep 11, 2008
    Posts:
    70
    I am the author of Darkstar Sharp, and my primary reason for developing the C# client SDK for ProjectDarkstar was for use with Unity3d. Please let me know if you have any questions about the library.
     
  6. RPGKHFan

    RPGKHFan

    Joined:
    Dec 29, 2008
    Posts:
    51
    You can make the server in Unity if you want to too. I am making my MMORPG server in Unity. I plan to make a nice guide explaining how to do this. It seems all of the other options don't utilize Unity's networking support, and use plugins, or cost money. I'm on a tight budget, as most people here, so it seems that a Unity MMO/networking tutorial would do some good.
     
  7. LDiederich

    LDiederich

    Joined:
    Jan 5, 2009
    Posts:
    15
    Hi tigeba,

    nice to see you here at the unity forum :)
    A guide or code example, how to integrate the library into unity and set up a client/server connection would be nice.

    regards


    Lars
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    any chance for a handfull of words on how to get the ugly cpu usage to an acceptable level, when not using OSX to run it, ie no headless mode.
     
  9. RPGKHFan

    RPGKHFan

    Joined:
    Dec 29, 2008
    Posts:
    51
    They don't have headless mode at the moment, that may be a feature Unity will implement in the future, however.
     
  10. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    So you are suffering the very same problem: the visual end is burning through 20-50% of a good P4 3.2ghz even with disabled cam and disabled static objects.

    if Unity just would give any documentation on their own network packet ids and the protocol of RPC and Network Syncronization, then it would be easy to write a C++ server or alike ...
    or is there documentation on that which I missed?
     
  11. RPGKHFan

    RPGKHFan

    Joined:
    Dec 29, 2008
    Posts:
    51
    Well, I know Unity is written in Rak Net, which seems to do alot of the hard stuff, might be good to check that out. Other than that, all I am concerned with the networking is the high level stuff. I am too poor to buy something else or learn something that low level and write it myself. Unity Networking has been going fine for me so far. Although, I'd probably check out RakNet if you are really concerned about processing speed. In my opinion, just do all the powerful stuff client-side.
     
  12. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    There was a CapFPS script somewhere here on the forums or in the Wiki. It simply uses Thread.Sleep(time) to throttle FPS. For a server, this is a very wise thing to use ;-)

    On there forums, it's at:

    http://forum.unity3d.com/viewtopic.php?t=931&highlight=capfps

    On the Wiki ... let me see ... nope, at least not by this name.

    In my game server, I'm having two states: When no users are logged in, I'm going down to 10 FPS (no need to waste CPU cycles in idle-mode), with users logged in, I have a value that I can change remote from my Masterclient. Usually, I'm going around 200, but I guess 50 should be fully sufficient (still playing around with this to find the sweet spot).