Search Unity

Should I use Unity's networking or not?

Discussion in 'Multiplayer' started by AzraelKans, May 8, 2010.

  1. AzraelKans

    AzraelKans

    Joined:
    Oct 29, 2009
    Posts:
    135
    Im trying to create a new unity multiplayer game, these are my desired features for this sports game (sort of)

    *is meant to be stand alone for windows/mac (iPhone in the future)

    *Players should join in a lobby, chat with each other via text (or voice if possible) then go into a 3 minute game.

    *Only 6 players are allowed per lobby/game.

    *You must be able to play online or in a lan. I have a master server of my own (called shadi)

    Now, what option would be best for my case? Ive heard the current unity network is not functional, so Im tempted with Photon but it seems expensive. ($100 per month)

    If I decided to go for my own implementation of Raknet what is the first step to make? also raknet is not a managed dll so Im not sure how to call it from unity.
     
  2. Creative

    Creative

    Joined:
    May 8, 2010
    Posts:
    184
    Yes, as an experienced RakNet user, I suggest you.
     
  3. AzraelKans

    AzraelKans

    Joined:
    Oct 29, 2009
    Posts:
    135
    Ok So I should use raknet, but where do I start? can I just call raknet as a dll from c#?
     
  4. Creative

    Creative

    Joined:
    May 8, 2010
    Posts:
    184
  5. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Can also take a look at SmartFoxServer - and the 4 example projects that I released for the Unity API.

    Might be somewhat easier and higher level to work with.

    Example 2+3 have lobby and chat premade for you.

    /Thomas
     
  6. AzraelKans

    AzraelKans

    Joined:
    Oct 29, 2009
    Posts:
    135
  7. AzraelKans

    AzraelKans

    Joined:
    Oct 29, 2009
    Posts:
    135
    Thank you, but could smart fox work in an stand alone product for macs?
     
  8. Kaiserludi

    Kaiserludi

    Joined:
    Jan 21, 2009
    Posts:
    94
    The Photon license costs are one time per server, not monthly.
     
  9. nevaran

    nevaran

    Joined:
    May 21, 2010
    Posts:
    247
    how about making ur own dedicated server and play withoud any of unity's networking help? i woud realy need it for ALOT of players and things...the untiy network is realy slow and u can bearly connect to a server :evil: :evil: i found a "master server" file but i dont know how to use it because it doesnt even have instructions :cry: if someone has a idea how to make it like in the source engine or something, reply
     
  10. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    If you want the game to be playable in LAN I suggest you use Unity's networking functions. 3rd party server software like Photon and SmartFox are for centralized authoritative servers usually for MMO's, and their licenses are meant to be used for those, not as LAN servers.
     
  11. bem13

    bem13

    Joined:
    Jul 1, 2010
    Posts:
    64
    Hi, Im not really experienced with networking, just trying to get my head broadly around the options.

    How do people use Smartfox Server with games where you want the server to call unity specific code such as physics emulation? It also seems (from my very brief look) that smartfox did not support UDP at least until the latest version, which implied to me it was not geared towards highly responsive fps games. I was wondering if Smartfox was more suitable to the lobby and managing large numbers of players, and an actual FPS multiplayer session should use Unity networking.

    Any good examples of responsive FPS in Unity, and what technology did they use?
     
  12. ExitBG

    ExitBG

    Guest

    Joined:
    Oct 16, 2009
    Posts:
    52
    Take a look at paradise paintball:
    http://paradisepaintball.cmune.com/
    They use Photon.
     
  13. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    In fact, Unity's networking is built on Raknet. So technically, when you use Unity's networking, you are using Raknet. If you search in the forums for Raknet, you'll find quite a bit of info. Unfortunately, it's more or less impossible to connect Unity directly to a Raknet based server (zumwalt ,correct me if I'm wrong - I think you got it working as far as it's possible to get it working).

    For LAN sessions, I would strongly suggest using Unity's built-in networking, as it will make things much easier for you. If you're planning to host your own servers ... I'd recommend Photon or SmartFox. Hopefully Unity 3 will solve many of the problems that were encountered in earlier versions, some of which likely were due to issues in Mono, while others might be fixed with the new version of Raknet that's now used in Unity 3.
     
  14. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Jashan, correct, I have gotten Unity talking to a dedicated true Raknet server, that is up to a point. Although they communicate, I simply have no way to decipher the messages that are being sent to it from Unity nor build a custom message to send to Unity from a pure Raknet server. At the moment, if you want a pure raknet server with Unity, you either build it yourself or use headless mode of Unity for the server. This has disadvantages because of several reasons, none of which matter at the moment do to the current architecture of Unity with Raknet integration.

    That "may" or "may not" change in the future. They are pushing to get U3 built and optimized, so any further assistance on this matter will wait until after U3 is released and everyone is sober again from the partying.
     
  15. bem13

    bem13

    Joined:
    Jul 1, 2010
    Posts:
    64
    I have had a look at Smartfox (and a very, very quick look at some docs on Photon)

    There is something about smartfox (and also Photon, from my quick glance) that I dont get.

    Unity networking seems to immediately deliver what I would expect: network objects, network instantiation, RPC on these objects.

    Smartfox instead lets me assign properties to rooms and users. These properties are just the basic types: ints, strings etc.

    This seems very limiting. Im not even sure how I could wrap this interface to give me the network-object model I want. It feels like if I wanted to publish a non-user, non-trivial object, eg a monster, I would have to do something like
    (myroom) key:"monster_23.hitpoints"=value:99
    (myroom) key:"monster_23.ammo"=value:44
    ..and so on..

    I must be missing something. My (very) quick glance at Photon also mentioned this room,user,properites pattern so im sure this must be a pattern that has served people well.

    I realize there is a SFSObject class that can be passed, and if I were writing a server in unity that was communicating via smartfox I expect I could fairly easily wrap this to give a network-object style interface. Is that something people do?
     
  16. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Because the Unity dev team built up a class object that can physically serialize and deserialize infinite amounts of objects in Unity, they are able to pass the entire object encapsolated (hopefully using gzip or something also) to the server which does what it needs to do with it.

    Thus, Unity's natural networking mode is setup for a sweet max 50 players based on bandwidth, otherwise it is like eating up an elephant when you only want an ant. Although you do not have to pass the entire object and all of its data, I haven't bothered to read the full packet stream from a Unity pass, but I presume from reading what everyone else has going on, this superclass that Unity wrote can serialize and deserialize at the component level within an object model, aka just the transform data.

    Basically what you send is what gets serialized and then translated and deserialized on the other end, so it is entirely possible to send the ant and get an ant, send a cow, get a cow, send a horse, get a horse, send an elephant, get an elephant.

    Everyone else gives you a skeleton model that you then have to build up your class that creates the object to send. I can't speak for U3 though, there is an architecture change between the models of U2 to U3 with Raknet utilization.
     
  17. ExitBG

    ExitBG

    Guest

    Joined:
    Oct 16, 2009
    Posts:
    52
    the room concept: all players that join the same room can exchange messages with each other.
    Photon has a "Lite" app that comes with source code for this approach, but using it is optional.
    Photon itself is just a socket server that allows you to add custom business logic with c#.
     
  18. bem13

    bem13

    Joined:
    Jul 1, 2010
    Posts:
    64
    Tell me more about this max 50 player limit. I have seen statements like that and also that it is better for lan games.
    But it looks like it has some decent options to customise what is sent, and I just noticed NetworkView.SetScope which allows you to not send all data to everyone (which I thought was what would have really limited it to a small open-arena fps type game)

    Hi ExitBG,
    Sounds like you are saying use the room and user properties just for bookkeeping values, and object data has to come by request from other clients, one of which could (if you like) have extra powers and effectively be a server written in unity, using smartfox for communication?

    I guess whenever a new player joins the room, any client in charge of certain network objects would have to send them for the benefit of this new client, because they are not stored in room data. I guess this could be staggered based on how close the existing client was to the new one, to avoid a sudden jump in traffic.
     
  19. ExitBG

    ExitBG

    Guest

    Joined:
    Oct 16, 2009
    Posts:
    52
    I haven't used smartfox, so can't really say anything about it. But yes, that's how you could do it with the Photon Lite app.
     
  20. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Frankly it depends on your skills as a developer. The Raknet source used in Unity is only a very small subset of the full Raknet. Seriously small subset, however, at least in U3 beta, they have the bitstream layer smoothed out from what I have tested, so you could make your own object and send only what you want, in what ever intervals you want. So in theory if you limit your scope of what to send and utilize the area that the data is limited to, you could optimize the number of people you are sending to and expand upon that. However, there is machine limitations to take into consideration, along with amount of available monthly bandwidth for services. The default connection number for Unity server is set at 1000, I know of no Indy based game using Unity networking at the moment that is beyond 100 players.

    Cartoon Network uses source and their own custom server from what I remember. Other people who have > 25,000 players are using either pure Raknet or Photon. Photon has at least 1 major game that has an active player base over 1 million with > 20,000 up at any given time. Raknet itself has networks with > 3 million people online at any given time globally if I am not mistaken, although Jenkins could chime in on that (aka Sony PS3 network).

    I just wish that Unity with U3 would add in the patch services, the database services, the compression services, the RPC4, and some of the other new improved toys that Jenkins crew has added to Raknet.