Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Ultimate Unity Networking project - Add multiplayer to your game today!

Discussion in 'Connected Games' started by MikeHergaarden, Jan 25, 2011.

  1. kerascoet

    kerascoet

    Joined:
    Mar 10, 2010
    Posts:
    5
    Hi Leepo,

    Nice work !!! I bought your Ultimate Unity Networking project yesterday and read/test everything but I would like to install the master server on my own server (os : Linux 2.6.29.4-167.fc11.x86_64) and I am not a linux expert... I downloaded all files from unity website (ProxyServer-2.0.0f1.zip, MasterServer-2.0.0f1.zip, Facilitator-2.0.0f1.zip, ConnTester-2.0.0f1.zip) but i am not familiar to how install and run these files... could you explain me how to install and run it, please ?

    I don't understand anything on the unity webpage (http://unity3d.com/support/documentation/Components/net-MasterServerBuild.html)...
     
  2. Lee Zhi Fei

    Lee Zhi Fei

    Joined:
    Apr 11, 2010
    Posts:
    100
    I tried to open the link but can't see anything but an error on page... any idea why?
     
  3. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    http://u3d.as/content/m2h/ultimate-networking-project/1ut
    The above link doesn't work for you? That would be weird. It's hosted by Unity so I can't change it.
    You can also simply browse to the package in the Unity asset store itself.

    @kerascoet
    You'll have to run 'make' to build the files (requires 'gcc'). If thats succesfull simply run the files. But you really need some unix knowledge. Maybe it's best to revert to the public unity masterserver for now. It's working great for me. Plus Dimerocker might still host a free masterserver for everyone?
     
  4. lubitel

    lubitel

    Joined:
    Feb 9, 2011
    Posts:
    3

    What was renamed to what to fix this?



    Also how do I "Run M2HNetworking ->Reset buildsettings" Is there a M2HNetworking menu that I am missing?

    I see the FixBuildingSettings file in "Editor" folder but the menu does not show up

    Thanks
     
    Last edited: Mar 4, 2011
  5. FalconRime

    FalconRime

    Joined:
    Feb 17, 2011
    Posts:
    34
    Congratulations on all the positive feedback. Does this require Unity Pro? And has it been tested on Windows version?
     
  6. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    I believe it was only the FPSChat or FPSExample or something... This is only a very minor change though. Either ignore it or redownload the latest version.

    Yes it should be visible in the Unity menu. However, if you have errors in your console log Unity refuses to build editor scripts, that must be the issue here. Resolve all open errors first.

    Thanks :). This works on the Mac&Window Unity editor. Furthermore, Unity networking itself works on all platforms but to use it on android and iphone you need the advanced licenses.
     
  7. lubitel

    lubitel

    Joined:
    Feb 9, 2011
    Posts:
    3
    Yes it helped re downloading a newer version.

    Un belivable:)
     
  8. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    607
    How many people can play online using this method? Could my game have a few thousand players playing at once?
     
  9. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,071
    No. Unity's built-in networking is client-server based where the server is typically another player, with a run-of-the-mill cable or DSL ISP; it's ideal for games with 8-32 players, depending on the complexity. That said, It would be VERY difficult (and probably impossible) to create a game with Unity that actually allowed thousands of players to be in one world, at the same time, no matter what middleware you used, as it doesn't support multithreading.
     
  10. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    607
    I am sorry I phrased my question wrong, however I appreciate your response. What I meant was can I have several games of 4 vs 4 or 6 vs 6 going on at the same time, possibly leading into thousands of players total? My game will ideally have small matches of 16 players max, I am wondering how many of those games can you setup with this method? If the game is popular could it handle hundreds or thousands of these small games at once? I am new to networking and I am sorry if that question is not asked correctly. Thank you for your time.
     
  11. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    You can have thousands of players, playing in seperate servers of size 4-32 players or so, yes.
    I.e. we have Crashdrive and Cubelands with +-800 concurent players playing multiplayer on 500 servers or so

    The thing is, the server are player hosted and only the masterserver is the required connection from our/your side.
     
  12. HunterDog

    HunterDog

    Joined:
    Mar 9, 2011
    Posts:
    7
    I'm probably an idiot, but where can I find the documentation?
     
  13. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,071
    i believe the pdf is in the package once you import it into your project.
     
  14. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    The .pdf file is in the root folder of the asset package.
     
  15. HunterDog

    HunterDog

    Joined:
    Mar 9, 2011
    Posts:
    7
    Thank you legend411 and Leepo!
     
  16. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    368
    I get some Errors on Scripts with Lines "List.<>"

    -----CompilerOutput:-stdout--exitcode: 255--compilationhadfailure: True--outfile: Temp/db6d8a62aaa59b0448410072b1046847.dll

    Assets/M2HNetworking/Example2/MultiplayerMenu2.js(154,33): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Example3/JoinMenu.js(24,28): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Example3/LobbyChat.js(60,42): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Example3/LobbyChat.js(147,44): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Example4/GameAssets/Scripts/FPSChat4.js(85,57): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Example4/GameAssets/Scripts/GameSetup.js(66,57): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Example4/GameAssets/Scripts/scoreBoard.js(43,78): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

    Assets/M2HNetworking/Tutorial 3/Tutorial_3_Spawnscript.js(7,28): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?



    I have reimported and redownloaded the package but I get the same errors. A Script with the name "List" ist not included in your package.
     
    Last edited: Mar 10, 2011
  17. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    "Error: Analytics Event:" <-- Very weird. Is that Unity's built in analytics somehow?
    Is this on iPhone? Maybe that doesnt support List in JS? They can be rewritten to ArrayList anyway.
     
  18. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    368
    No. I work with windows system. It seems that the Class "List" is missing in your package ?
     
    Last edited: Mar 10, 2011
  19. kheng

    kheng

    Joined:
    Oct 22, 2008
    Posts:
    126
    I get the same error as Gaspedal when I open the project in Windows with Unity Basic. But on the OSX it works fine. Also on windows the buildsettings tool does not work.
     
  20. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,071
    Leepo, I downloaded the project the day you released it... I went to update it yesterday but it says I'm up to date, and the asset store keeps freezing halfway through my download if I say "redownload anyway" or whatever, am I missing any important updates or bug fixes?

    My current project is basically using example 2 as a framework.
     
  21. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    368
    @Leepo:

    I have solved the Problem. You have forget to add....

    "import System.Collections;"
    "import System.Collections.Generic;"

    ...on the top of java scripts. Now it works! :)


    List is a NET Framework Class :

    Conversion of DataTable to List<T>

    using System;
    using System.Data;
    using System.Collections.Generic;
    using System.Text;
    using bl = sampleBL;

    found on: http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx#Y8944
     
    Last edited: Mar 10, 2011
  22. alienheretic

    alienheretic

    Joined:
    Oct 15, 2008
    Posts:
    55
    i had the same issue using Unity 3.03.0f3(63049)

    fixed as Gaspedal posted above

    "import System.Collections;"
    "import System.Collections.Generic;"
     
  23. rajmond

    rajmond

    Joined:
    May 18, 2010
    Posts:
    56
    Hi

    Just wanted to ask Leepo (or someone else who knows) about the "Exampe2_menu" from this tutorial. When I want to join a server and I see the server available, how can I decide which scene to load when I press a button (servers running)?
    I'm asking this because I want to use the master server and the menu for multiple scenes.

    Thanks in advance.
     
  24. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Thanks Gaspedal. Unity 3.3 seems to be more strict and now requires that import in JS. I updated the files with this fix. Is everything working for everyone?

    rajmond: You'll have to create that logic yourself. Note that RPCs only work if the networkViewIDs are exactly the same. This can be a bit troublesome between scenes. Using Example2 you could use the masterservers comments field to save the level int in there, and have clients load that level at a succesfull connection. In the document there is a brief section about this (it's a bit hacky, but works well enough)
     
  25. porvas20

    porvas20

    Joined:
    Oct 25, 2010
    Posts:
    14
    i am making a fps project for the university. i am using the example4 of your tutorial.. when more than 2 player join the game all the players can update the scoreboard and view their kills and deaths and the servers kills and deaths and vice versa. I have noticed that the clients dont update the scoreBoard between them! How can i fix this ?
     
  26. rajmond

    rajmond

    Joined:
    May 18, 2010
    Posts:
    56
    Hi Leepo,

    Actually I found out a more easy and fast way for this. When I register a game in the master server I give it the name of the scene it self. Then the other clients in the list see the name of scene as a button text/tittle, and when they click on that button I say to load that scene with the name of the button text/tittle.

    Anyway thanks for the help :)
     
  27. nielsmillikan

    nielsmillikan

    Joined:
    Nov 29, 2010
    Posts:
    72
    I can't download the tutorial pdf. Please re-upload it.
     
  28. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,503
    I purchased this yesterday, and it's been a very big help in helping me actually see how things fit together.
     
  29. OldMonk

    OldMonk

    Joined:
    May 22, 2010
    Posts:
    22
    I purchased this tutorial and am finding it helpful. I have however, run into a problem that I am hoping the community can help with. In my game, I have a ShipPrefab that is composed of several components. For example,

    ShipPrefab
    - Near Camera
    - Far Camera
    - Model
    - Various Scripts

    Each player controls a ShipPrefab. Should I create a special RemoteShipPrefab that only has the Model component? Example:

    RemoteShipPrefab
    - Model

    The reason I ask is because it seems like a waste to create a prefab with information that isn't necessary. For example, if I have Server and Client A and Client B, and each controls a ShipPrefab, it seems like a waste to have Client B instantiate three ShipPrefabs. The reason I view it as a waste is because Client B could care less about the cameras on the other two ShipPrefabs?

    Thus, I thought that since the actual model is all that needs to be shared, I should create a special RemoteShipPrefab that only contains the model.

    Any insight is appreciated...

    -OldMonk
     
  30. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Yep you could create a remote and a local prefab perfectly fine. It's a good idea since it'll never switch from remote to local or vice versa anyway.
    As for our own games so far I alway used one prefab and enabled/disabled scripts depending on whether it was local or remote.
     
  31. darkben

    darkben

    Joined:
    Jan 8, 2011
    Posts:
    405
    oh damn. where am I going to get 80 euros from? >.<
     
  32. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    Hi Leepo,

    I just bought your tool and am waiting for further instruction.
    BTW, shall we get the free update in future? (eg. photon server info.)

    Thanks in advance
     
  33. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    You should be able to download it directly after purchasing.
    Yes if Unity 3.X updates bring new networking fixes/features I will update the project accordingly (For free)
     
  34. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    Thanks a lot, downloading now. (I just noticed the button caption is replaced with "download")
    I have been dreaming to build a simple network game easily
    :)
     
  35. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    Sorry, after pressing the "import" button, I got the following message:
    http://img638.imageshack.us/i/faileu.png/

    Then I need to press "try again" button twice to import.
    Then I got error message for examples and tutorials inside unity. The content of editor log is put in a zip file below.

    What's wrong with me?


    (I am using win xp sp3 and unity pro 3.3.0f4)
     

    Attached Files:

    Last edited: Apr 5, 2011
  36. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    Now I am going to try Gaspeda's solution above. The download version in the store is still missing these lines of code, I believe...

    But why I need to press "Try Again" twice to import?
     
  37. tbryant

    tbryant

    Joined:
    Aug 12, 2009
    Posts:
    17
    I'm hoping this is the right thread:
    I've just imported the Ultimate Networking Project into my project (glad to have it, by the way, I started with the M2H tutorials in Unity 2.x and was frustrated through the bugs in 3.x, and am paying because I want the updates.) - thanks Leepo. :)

    on importing I get this:
    Assets/Standard Assets/Scripts/FPSWalker.js(10,21): BCE0005: Unknown identifier: 'FPSChat4'.

    I moved FPSWalker.js to M2HNetworking/Example4/GameAssets/Scripts/ and renamed it FPSWalker4.js which cleared the error, but I'm not sure that I have the correct script.

    I am planning to use the C# scripts for my project anyway, but I thought I'd report it here.
     
  38. OldMonk

    OldMonk

    Joined:
    May 22, 2010
    Posts:
    22
    Thanks Leepo. How would I do this though considering that each prefab's information is shared via its network view and now there would be two different prefabs that would need to share data...

    Also, is your way any more/less efficient as far as memory consumption goes? What does it mean for a script or item to be disabled? Does that mean it gets cleaned up by garbage collection? I don't think it would mean that....

    Thanks,

    OldMonk
     
  39. rajmond

    rajmond

    Joined:
    May 18, 2010
    Posts:
    56
    Hi Leepo,

    I'm using your example 4 menu. It works fine but when I compile the web player and try to connect from a computer I cannot connect. But when I host first, then go back to the menu then I can join servers that are running. Any idea?
     
  40. MetaMythril

    MetaMythril

    Joined:
    May 5, 2010
    Posts:
    150
    Just bought and downloaded. Getting some warnings for a few files:
    Isn't much of an issue to fix, just thought you should know that I didn't have a clean import experience. Looking forward to going through your material. :)
     
  41. Xentar

    Xentar

    Joined:
    Apr 8, 2011
    Posts:
    22
    I'm a total newbee, so need to ask.
    If i use this method to do a simple "vs" game, this can be in web browser and work fine?
    Right now me and a friend want create a "simple" FPS game, with user registration (facebook addon i presume) and highscore, but we are designers more than programmers... so this could end being our bible, hehe

    Thanks in advance
     
  42. moria15

    moria15

    Joined:
    Feb 25, 2011
    Posts:
    390
    Greetings.

    OK LOVEEEE ultimate networking, I'm not a coder and even I managed to make progress with this, although others would probably know all that I am about to ask by instinct.. just call me stooopid :)

    I thought I was doing really well today.. I managed to set up a project and add Ultimate networking and then instantiate players at random spawnpoints and watch the characters move without getting all confused with which camera was being used using third person views of the character.

    In order to stop each player controlling the other players characters, I had to use

    Code (csharp):
    1.  
    2. function OnNetworkInstantiate (msg : NetworkMessageInfo) {
    3.     // This is our own player
    4.     if (networkView.isMine)
    5.     {
    6.         localPlayer=true;
    7.     }
    8.     // This is just some remote controlled player, don't execute direct
    9.     // user input on this. DO enable multiplayer controll
    10.     else
    11.     {
    12.         var tmp1 : Controller = GetComponent(Controller) as Controller;
    13.         tmp1.enabled = false;
    14.     }
    15. }
    16.  
    in my player script. This is fine, but the problem I now have is that this Controller script also controls the animations of the character and so although the character animates correctly on their own screen, on other players screens they are just drifting with the default animation... very surreal.

    What is the recommended method for passing the animations to other players from a script that is ignored on the network messaging please.

    Regards

    Graham
     
  43. moria15

    moria15

    Joined:
    Feb 25, 2011
    Posts:
    390
    wooot solved it :)

    Didn't realise you can send RPC messages from a script you have disabled.

    Happy again :)

    Regards

    Moria
     
  44. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    659
    I have purchase this and while it has cleared up a few things, still having some issues.

    I am trying to replicate the tutorial 2B and the issue I am running into is that the player connecting as a client can't move their cube but the player who created the server can. Any ideas why this might happen?
     
  45. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    659
    I figured out my problem, and it was a dumb one at that.
     
  46. MetaMythril

    MetaMythril

    Joined:
    May 5, 2010
    Posts:
    150
    Would you kindly edit your post to explain how you solved your problem for the sake of others that may run into a similar issue that may read this?
     
  47. foxter888

    foxter888

    Joined:
    May 3, 2010
    Posts:
    530
    is there a problem with nat punchthrough? i tried using the networking example withouth messing with it and no one can host the game and same for the m2h tutorial, but if i configure my router to have nat open then i can finally host the games and have people connect to me.
    what's going on here?
    before it was working the networking tutorial and the m2h tutorial was working correctly letting people being able to host and such but now it's like all the suddes no one can use it.
     
  48. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Some connections will simply -not- be able to use NAT punchtrough. See the table here: http://www.raknet.net/raknet/manual/natpunchthrough.html

    Are you sure your network setup was exactly the same? What Unity version was that?
     
  49. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    152
    All links to the project are broken. The project itself cannot be found in unity store. And the links leads to a fake u3d.as domain website with unity 3d skin but IS NOT unity 3d website. All this smelt fishing.
     
  50. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    974
    Heh, no need to worry: You must have overlooked it in the asset store, please check the Unity asset store again (Complete projects -> Ultimate... or search for networking/multiplayer) and copy the projects link from there, you'll see it's the same. Ask Unity why they went for that weird u3d.as domain name though.