Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'Multiplayer' started by MikeHergaarden, Jan 25, 2011.

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Appels: Why would Application.runInBackground = true prevent the error "A client which was not in the connected player list disconnected." from happening? Can you give us some insight into what is causing this error? TBH, I have not seen this error often, and as I had bigger fish to fry, assumed that if it were to continue as a problem, I'd sort it out later, so I have not tracked any causal behaviour for this error.
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    I have seen the error before when it was not set in a webplayer. The client instance could not connect to the server because the server browser window was not focused. I got the error when the server instance webbrowser got the focus but then the client closed.
     
  3. InterstellarGames

    InterstellarGames

    Joined:
    Jul 5, 2011
    Posts:
    17
    Someone needs to create an extension to this with a better example project, more like an almost complete game. With animations, player names over head, and a character selection for players to have unique prefabs instead of every player being a duplicate of the same box. I know a lot of people would buy this, it would probably be one of the best assets to hit the store, especially if it was a 3rd person shooter. ;)
     
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    In the Multiplayer Functions... I notice that in "Awake()" there is an attempt to both "TestConnection()" and "SetupMasterServer()". Later, if one tries to "StartServer()" there is a Debug.Log warning triggered if either "TestConnection()" or "SetupMasterServer()" has not completed.

    Ok...

    What I don't understand in this is "SetupMasterServer()" simply seems to be a "FetchHostList()".

    I'm confused.

    If I'm working on an analogy that the player has chosen "Host" not "Join", why should it be a requirement to "FetchHostList()" prior to running "StartServer()"?
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Another confusion... Could just be I'm unclear what is Asynchronous but:

    It seems that you ask for the host list with: MasterServer.RequestHostList(masterserverGameName);

    Then wait until the MasterServerEvent returns: MasterServerEvent.HostListReceived

    But what is confusing me is that the sample code, then runs the MasterServer.PollHostList thru a while loop until MasterServer.PollHostList().Length == hostData.Length

    But hasn't the MasterServerEvent already told me that the HostList was Received?

    Why do I need to wait and check the length of the MasterServer.PollHostList against the length of the hostData?
     
  6. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Yep, it does not make sense for when hosting. We do need the correct masterserver IP by the time we start a host though, so that we can register the new game. I believe that in this case the


    The annoying thing here is that the masterserver updates are send one by one..So this code is in place to ensure calling the delegate once the entire list has been send (once the length stays the same we assume that the sending is done
    )
     
  7. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I was working on the logic of:

    Code (csharp):
    1. (MultiPlayer Game)
    2.      |
    3.     / \
    4. (Host)      (Join)
    5.    |          |
    6. Server Name Display List of Games
    7. Password        (Fetch Host List)
    8.  
    But I suppose this assumes the player knows whether they want to host or join,

    where as:

    Code (csharp):
    1. (MultiPlayer Game)
    2.      |
    3. Display List of Games
    4.      |
    5.     / \
    6. (Host)      (Join)
    7. Server Name Display Lobby
    8. Password
    9.    |
    10. Display Lobby
    ... would put the control back into the hands of the player to look at the list and then decide to Host or Join.
     
  8. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664

    You were cut off...

    Speaking of which, why does getting the host list give you the correct masterserver IP?
     
  9. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Just an FYI, since 3.4 you have to import System.Collections.Generic now in any of Leepo's scripts using Lists.
     
  10. project

    project

    Joined:
    Apr 25, 2009
    Posts:
    45
    I have a few questions about using this product which I have purchased :)

    Does anyone know how I would go about doing split screen? or if its... I dont want to say possible because anything is possible but would it be practical to try and attempt something like this with M2H's product?

    For example when the game starts I hit a button to connect to the server, then theres a quick match button which is like a lobby with no GUI elements.

    Then I would have 2 buttons "Start" and "Exit" (in the middle of the screen which is a split screen) From the split screen I can see the other players avatar and they can see mine or simpler I can see their name (right hand side of screen) and they can see mine (left hand side of the screen).

    Who ever hits the "Start" button first becomes the server and the other player is the client. when both players have hit the start button the game starts. I have a full size split screen on my side and I can see their smaller split screen in the corner of mine, and on their side it looks the same they have a full size screen and can see my small size screen in the corner. If the other player does not hit start in 20 seconds it will randomly pick another player from the master server list which is invisible.

    But back to it I know how to do split screen with Normalized Viewport Rectangle and 2 cameras but how would I create 2 game sessions that are linked so I can see what they are doing and they can see what Im doing for example they shoot balls into a hoop and I shoot balls into a hoop however we both play different games in a sense because their not inside of my full screen and Im not in theirs but who ever reaches 5 first wins and we are both connected to see each others scores.

    Its really tough getting my head around all of this but Im trying my best being new to networking.

    Any ideas on how to achieve the above?

    Project,
     
    Last edited: Aug 7, 2011
  11. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    You don't need 2 game sessions, you just need 2 camera's that follow the 2 players, the local player on the left cam and the remote on the right.
     
  12. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Split screen has little/nothing to do with mutliplayer, this project can not help you here.
    Split screen is all game logic, whereas the key of multiplayer is about synchronizing data over the network. With split screen multiplayer this is already the case.
     
  13. project

    project

    Joined:
    Apr 25, 2009
    Posts:
    45
    That does shed the perspective I was looking for :) I was thinking about it all wrong, Thanks "appels" and Leepo".

    So if Im thinking about this right and back to my example, in my scene id need to have 2 basketball courts and 2 cameras(for split) in one scene and follow the FPS Example for scores, and as appels suggested have the local player start in one court (with one camera) and have the remote player start in the other court (with the other camera) and just synchronize the scores.

    This is AWESOME!
     
    Last edited: Aug 7, 2011
  14. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Project: There are some issues with what you want to do that ARE networking related, but I don't have time to talk about that until tomorrow.
     
  15. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    Why do you want 2 scenes ? You don't need it. Read what i write, 1 session ONLY.
    Spawn 2 players in a scene, have 2 camera's in the same scene, each follow 1 player and split the screen.
    Not 2 scenes, not 2 basketball courts, 1 only.
    You only need 2 players, the local and the remote one IN THE SAME SCENE.
     
  16. project

    project

    Joined:
    Apr 25, 2009
    Posts:
    45
    Yes appels 1 session only! and with 2 cameras.

    But in this 1 session (scene) I would need to create 2 courts because I dont want to see the other player shooting at the same hoop in the scene, I only want to see my player and the other player in the split screen (top right) so it looks like he's somewhere else tough to explain, but it would kind of be like a versa mode or playing solo but I can see what the other player is doing, if that makes sense I know you might not understand why but i'll try and find a game with a link thats got the same type of style :) when I get home tomorrow ;)

    @Little Angel
    That would be awesome my friend! The network related stuff is what Im after and I can already see some issues coming... So any input would be greatly appreciated.

    Project.
     
    Last edited: Aug 8, 2011
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Project: Don't forget layer masks. If you need two objects in the same scene, but ignored by a particular camera, put the objects of different layer masks. You could put player1 and ball1 one on PlayerLayer1, and player2 and ball2 on PlayerLayer2, have two cameras and set camera1 to ignore PlayerLayer2 and camera2 to ignore PlayerLayer1. You can't really have two scenes running at the same time.

    Where you are going to run into issues, at least with vanilla "out of the box" Unity networking, is seeing the other player before you actually connect.

    This can't really work the way you see it: Who ever hits the "Start" button first becomes the server and the other player is the client. and how would I create 2 game sessions that are linked so I can see what they are doing and they can see what Im doing for example they shoot balls into a hoop and I shoot balls into a hoop however we both play different games in a sense because their not inside of my full screen and Im not in theirs but who ever reaches 5 first wins and we are both connected to see each others scores.

    With Unity's basic networking, you can poll a host list and see what games are available, but until you actually connect and one player is the host and the other is the client, you are not connected and you are not synchronizing data. There is one field, "comments", which can hold some data if it's text or serialized information, but other than that, the amount of information that is available to a user is limited to this:
    http://unity3d.com/support/documentation/ScriptReference/HostData.html

    And this is only from players that have chosen to HOST. Players not actively hosting, but browsing for a game are never seen.

    You could, in comments, save information about things like the avatar of the chosen host, and your client who is browsing for a new game could cycle thru the available host games and have the avatar displayed, along with game type and custom details, but you couldn't see what they were doing without forming a host/client relationship with one of the players.

    It *could* be possible that you connect to the host as a client and have the game go into a lobby mode where you get that functionality, but then you'd have to realize you now have a host/client relationship running, and the host would see every client connected and if they chose "start", they'd also have to select which of the connected clients they would be starting with, and the others would get kicked off (or put into spectator mode without their consent).

    The only other way would be to run a persistent "headless" Unity networking instance acting as a server with a lobby, but that's an analogy that's not covered in this tutorial, and frankly, there are few if any tutorials describing this on the forum.

    You could also do this by running a server using alternative code (other than Unity's built in networking), like uLink, Photon, ElectroServer, etc..

    Try thinking about it: If you want to see what another player is doing, you need to be connected to them and synchronizing data. In the host/client master server concept used by Unity's networking, you'd need a single direct connection between a client and a host and they would only be able to see each other. With a central server, you could have all of the clients in rooms and have the central server synching data between them, but you'd need to code this central server as well as your game. You'd also need to have some way of resolving the conflict of what would happen if player a and player b were both watching player c, and both a b chose start. What would happen with player c? Would they see both other players? What would happen if player c hit "start" while both a b were browsing his game?

    Explore the complexity of what your asking, and then consider: "Is this necessary for the game? If not, is it just 'eye-candy'? If so, is is worth the headache?"
     
    Last edited: Aug 8, 2011
  18. project

    project

    Joined:
    Apr 25, 2009
    Posts:
    45
    Hey Little Angel Great Insight!

    Im definitely going to take a day or 2 and see how I can restructure it :) I guess the I candy aspect really isn't worth it, especially being a noob to networking. You've given me much to think about and I SERIOUSLY appreciate it! So close but yet so far lol

    I'll post back again and let you know what I come up with :) again thanks a million!!!

    That goes to you too appels Thank you! very much :)

    NOTHING BEATS THE UNITY FORUMS EXCELLENT ADCIVE AND GREAT PEOPLE!
     
  19. aleksbgs

    aleksbgs

    Joined:
    Dec 25, 2010
    Posts:
    31
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Aleksbgs:

    To be fair, Leepo's tutorials could use a lot of work, yes. In many cases they are under-documented, hard to modify and poorly commented.

    In his defense, however, they do work out of the box and they are the only viable tutorials available for Unity's built in Networking API. Even Unity Technologies do not provide a tutorial for their own code, much less a good one.

    Photon is not free and is an additional multiplayer solution available for purchase from a third party and requires a dedicated host (which is usually an additional monthly fee), while the built-in networking can rely on Unity's hosted Master Server, which for development, practice, learning and simple games is a viable and free solution.
     
    Last edited: Aug 9, 2011
  21. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    548
    Im having some difficulty with Example 4 if anyone can help?

    I replaced the player with my own player just seeing how things worked, then added all of the scripts from m2h's player to my player and believe I set up almost everything exactly and just cant figure out how to have my new (replaced) player get the pickups?

    I get 2 errors:

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. Pickup.Pickup (UnityEngine.GameObject object, .PlayerScript playerScript) (at Assets/M2HNetworking/Example4/GameAssets/Scripts/Pickup.js:47)
    4. Pickup.OnTriggerEnter (UnityEngine.Collider other) (at Assets/M2HNetworking/Example4/GameAssets/Scripts/Pickup.js:41)
    5.  
    this is line 41
    Code (csharp):
    1.  
    2. function OnTriggerEnter (other : Collider)
    3. {
    4.     var object =  other.gameObject;
    5.     var playerScript : PlayerScript = object.GetComponent(PlayerScript) as PlayerScript;
    6.    
    7.     if(isActive)
    8.     {
    9.         [COLOR="red"]Pickup(object, playerScript);[/COLOR]
    10.        
    11.     }
    12. }
    13.  
    and line 47
    Code (csharp):
    1.  
    2.  
    3. function Pickup(object : GameObject, playerScript : PlayerScript){
    4.     [COLOR="red"]if(!playerScript.localPlayer)[/COLOR]{
    5.         //Only the local player can pickup his own item
    6.         return;
    7.     }
    8.  
    I haven't changed the code so I have no idea what Im missing and I've been back and forth back and forth a thousand times trying to see what Im missing and just can't figure it out?

    Can anyone help and has anyone ran into this problem?
     
  22. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    It's clearly the "playerScript" that is causing the nullref.
    When/where is it set?
     
  23. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    548
    its on the top object that holds my Player and scripts, here is a screen shot......

    Oh.., the one thing Im noticing thats different is the Network View, in yours it looks like a script is attached and in mine Im observing the Transform. Could this be the problem and if so how would I fix it? I guess I assumed wrong and just dropped the transform in this field because it was empty.

    If this is not the case Im still lost? hmm... the only other thing I think I changed was the path to the Weapon Machinegun script. I did remove the FPSWalker script.

    Code (csharp):
    1.  
    2. function OnNetworkInstantiate (msg : NetworkMessageInfo) {
    3.     // This is our own player
    4.     if (networkView.isMine)
    5.     {
    6.         //camera.main.enabled=false;
    7.  
    8.        
    9.         localPlayer=true;
    10.         networkView.RPC("setName", RPCMode.Others, thisName);
    11.        
    12.         Destroy(GameObject.Find("LevelCamera"));
    13.         thisName=PlayerPrefs.GetString("playerName");
    14.        
    15.         [COLOR="red"]var gun : Machinegun = transform.Find("Weapon").GetComponent("Machinegun") as Machinegun;[/COLOR]
    16.         gun.localPlayer=true;
    17.        
    18.  
    19.        
    20.     }
    21.     // This is just some remote controlled player, don't execute direct
    22.     // user input on this. DO enable multiplayer controll
    23.     else
    24.     {
    25.         thisName="Remote"+Random.Range(1,10);
    26.         name += thisName;
    27.    
    28.         transform.Find("CrateCamera").gameObject.active=false;
    29.         /*REMOVED
    30.         var tmp2 : FPSWalker4 = GetComponent(FPSWalker4) as FPSWalker4;
    31.         tmp2.enabled = false;
    32.         var tmp5 : MouseLook = GetComponent(MouseLook) as MouseLook;
    33.         tmp5.enabled = false;
    34.         */
    35.         networkView.RPC("askName", networkView.viewID.owner, Network.player);
    36.        
    37.    
    38.     }
    39. }
    40.  
     

    Attached Files:

    Last edited: Aug 19, 2011
  24. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    548
    Thinking about your question:
    its called when my player enters the trigger, which makes me believe.... Tough stuff. Im going to keep on trying though ;) Sorry about the post above I dont think the Observed has anything to do with it.
     
  25. matusel3

    matusel3

    Joined:
    Aug 24, 2011
    Posts:
    3
    I am fairly new to programming and I was thinking of purchasing this package in order to learn more about networking in Unity, and potentially make a small network game.

    My question is, will I be able to take this and be off and running fairly simply, with the ability to learn as I go, or will this entail quite a bit of work and setup for me to start playing with it?

    I do not have any issue with learning the basics ahead of time, but I find it much easier to learn by getting my feet wet with something.

    Thank you for your time,

    Matt
     
  26. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    IMO, it's very easy to grasp, assuming you have a firm grasp on working and programming in Unity. If you're just starting, I'd strongly suggest working on single player stuff first, even if its working through all the official tutorials, doing the TornadoTwins series, the BurgZergArcade series, and then come purchase this package. The server creation/master server list GUI and all that stuff is taken care of for you with the example projects, and you can just use one of them to get into the nitty-gritty network messaging and synchronization stuff, which is explained pretty well between the PDF tutorial, reverse-engineering some of Leepo's examples, and the Unity docs.
     
  27. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    712
    Could I use this tutorial and Uscript to implement some multiplayer without coding knowledge?
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    rmele09: That's hard to say. You must understand enough basic coding to PREP your game for multiplayer even if you borrowed one of the example frameworks for connection. You must have a grasp of RPC calls and State Synchronization and how to use them.
     
  29. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    712
    Is it easier to setup LAN multiplayer than master server type multiplayer?
     
  30. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Not really as the first steps are not HOW you connect to anther game, but how you design your game to work with multiple players. The biggest difference is that as opposed to having two controllers in one game (say a wii in your living room) you have two independent games running on separate devices that you as the developer need to keep in synch.

    What I'd do first, if I were you, would be to take the star-trooper multiplayer tutorial and or the Unity2.0 version of this package (both free) and see how far you get. If you're doing well, then spring for this package.

    In any case you will need to learn how to grasp RPC calls and State Synchronization and learn how to use them.

    My biggest worry is your note of without coding knowledge. It will take some coding.
     
  31. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    That question is a contradiction... to use UnityScript implies coding knowledge :)

    But no... without learning a bit of programming, you will not make a multiplayer game. You should do what I said in my previous post.
     
  32. cozza13

    cozza13

    Joined:
    Dec 13, 2010
    Posts:
    64
    Using the project I seem to be having trouble with a NAT. I will have a room listed fine but then when I try to join it says "joining" and never joins. I get this message from the log "TestConnection result: testedUseNat=True connectionTestResult=NATpunchthroughAddressRestrictedCone probingPublicIP=False hasTestedNAT=True testMessage=NAT punchthrough capable. Can connect to all servers and receive connections from all clients. Enabling NAT punchthrough functionality." saying it is using NAT but then it does not connect.

    Are there some other debugging tricks I can use
     
  33. shiba_nivengo

    shiba_nivengo

    Joined:
    Apr 20, 2011
    Posts:
    16
    Hi,
    I'm getting the following error messages when I start an online game:
    - Could't invoke RPC function 'launchGame' because the networkView 'SceneID: 3 Level Prefix: 0' doesn't exist
    - Could't invoke RPC function 'addPlayer' because the networkView 'SceneID: 3 Level Prefix: 0' doesn't exist

    Sometimes I get only one, sometimes both and sometimes none. Does anyone know what I'm doing wrong?
    Thank you very much.
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    shiba_nivengo: Can you give us some more information? The errors say exactly what the problem is on a small scale: A network view doesn't exist. Why this network view doesn't exist cannot be tracked down unless you send us some more info. Try to track down who is asking for this network view, and why that network view doesn't exist.
     
  35. Fratyr

    Fratyr

    Joined:
    Sep 5, 2011
    Posts:
    20
    Looks very nice, I'm willing to buy It.
    Too bad It lack the information I'm seeking...

    I was wondering if you could extend/make new one and describe some aspects of making RPG/RTS games in multiplayer.
    Registering user via web, database interaction, some basic leveling mechanism, and of course - how to create a huge world illusion.
    (Prefabs auto loading/switching scenes or however It's done nowadays).

    I even ready to pay for a private education on this topics and some more. Do you wish to provide that kind of a course? :)
     
  36. faris

    faris

    Joined:
    May 30, 2011
    Posts:
    4
    Hello!

    I'm implementing a car racing game which needs an online multiplayer engine (such as ElectroServer) plus physics engine.

    1- Does your project support Online networking (WAN) or just local network (LAN).
    2- Does your project support the physics engine data transmission.


    Thanks in advance.
     
  37. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    online multiplayer engine (such as ElectroServer)
    -Do mind that Unity networking is a networking engine on its own. This project is only about Unity networking.

    1: Unity networking (UN) supports both
    2: Since servers/clients all run as Unity players, phsyics is supported by Unity itself. But players need to host games themselves (no dedicated servers)
     
  38. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    I just bought the package today and I've gone through the tutorials and examples. Very methodical approach and easy to understand - so thank you, great work!

    The Master Server examples do not work for me however. When I host a game the debug log says "OnMasterEevent: RegistrationSucceeded" - but on a client the server does not appear. The client gets the "OnMasterEevent: HostListReceived" debug message, but the list seems to be empty as no servers appear.

    Am I missing something that I need to do? I am trying it by running the host in Unity and the client in a WebPlayer locally on the same computer.
     
  39. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    The Unity masterserver is for testing purposes only and might be down at times.
     
  40. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    All due respect to appels, but I'm not sure if this sounds like an inactive master server. If imphy is getting "OnMasterEevent: RegistrationSucceeded" and the client gets "OnMasterEevent: HostListReceived", that sounds like the server exists. Unfortunately, connecting thru the internet is a bit arcane.

    imphy: I assume that you are using the examples straight out of the box? And they don't work? Yet I assume that you can connect to the internet "normally" for other tasks? Browsing and Games?
     
  41. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    @Little Angel - yes I'm using them straight out of the box in Unity 3.4 and all the tutorials examples work beautifully except the Masterserver function in Example 3,4,5. I have full internet connectivity for browsing and gameplay. I'm behind a firewall (I use pfSense) but NAT is "Open" in games such as Modern Warfare 2 etc.

    If it was a NAT punchthrough issue I would still expect the server to be visible from the "Join" screen of the examples when refreshing the list (but then maybe not be able to actually join them), right?

    I also enabled Network debugging in unity, when I host a server I get the following:

    Attempting to connect to master server at 67.225.180.24:23466

    Connected to facilitator at 67.225.180.24:50005

    Connected to master server at 67.225.180.24:23466

    Sent host registration to master server, registering a NAT assisted game as
    "Guests server", 1, 8, not password protected, "Servers description"

    Received identifier 0 from master server

    4.409244 OnMasterEevent: RegistrationSucceeded

    TestConnection result: testedUseNat=True connectionTestResult=LimitedNATPunchthroughPortRestricted probingPublicIP=False hasTestedNAT=True testMessage=Limited NAT punchthrough capabilities. Cannot connect to all types of NAT servers. Running a server is ill adviced as not everyone can connect.
     
  42. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Just noticed the typo: "adviced" instead of "advised" in "Running a server is ill adviced"...

    Humph... Looks like it could be your setup? If TestResult=LimitedNATPunchthrough Cannot connect to all types of NAT servers.

    But that's purely my responding the the Connection Tester results...

    Can you look through the code and see what actual condition returns Cannot connect to all types of NAT servers?
     
  43. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I believe there is/was some code in the master server list where it hides NAT enabled servers if you yourself cannot do NAT?
     
  44. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    Thanks for helping out.

    I identified that this is the case the Tester results with: "ConnectionTesterStatus.LimitedNATPunchthroughPortRestricted"

    As I mention, I use a firewall called pfSense that uses Symmetric NAT by default, but I have reconfigured it to do Static outbound NAT which should be equivalent to Full Cone NAT if I understand it correctly (what a jungle NAT is... and I work with firewalls...)

    I have also tried to go through my Cisco Linksys WRT320N router instead of pfSense - but apparently that device also has a very poor uPnP implementation. Imagine the average player trying to figure these things out, can't wait for a revolution - maybe IPv6 in half a century or so :)

    Anyhow - I'll continue to try to get my Unity network tester to result in "ConnectionTesterStatus.NATpunchthroughFullCone" - any suggestions and assistance would be much appreciated. I will report my progress if I get it to work in the meantime.

    @Leepo - it would make sense if it's hidden - can the raw server list be verified somehow?
     
  45. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Unity does not hide things from the list for you..Unity gives the raw list. But I remember I had some code in my example masterserver GUI code that checked for NAT status for the host and the local client. (Unitys own networking example had this for sure).
     
  46. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    Leepo - I couldn't find any conditions to filter out NAT servers in your code (but I did see it in the Unity example now as you mentioned) - so that can't be the issue then.

    I have also tried to launch the server on my computer which uses pfSense firewall/router and one public IP address - and then I launched the client on my wife's computer using the WRT320N router with another public IP address. I also tried the other way around (host on her computer and join on mine) - but the server list remains empty.

    I should also mention that I'm quite new to Unity and I'm still learning a lot so if there is anything obvious that I should have assumed to have done - please let me know :)

    (UPDATE: Also - this could be useful for some people that experience NAT problems: http://nattest.net.in.tum.de/?mod=results - nearly all the routers seem to use Port-Restricted NAT and most of them appear to not be able to perform UDP holepunching)

    UPDATE2: What is also interesting is that I'm running Wireshark to capture the traffic now and when I host a Example2 on my wife's computer (currently public IP x.225.91.46) I see in the captured UPD traffic on my computer from the master server (67.225.180.24) that one packet contains "x.225.91.46.5:5" which is my wife's IP address but with the added ".5:5" which looks a bit odd... So the master server seems to be aware of the server but the client isn't listing it - maybe the master server response is corrupt...hm.... (btw. I captured the traffic right when I clicked on "Refresh List" on the client in Example 2)

    UPDATE3: I asked a mate of mine to run the Example 2 in the WebBuild as well and when he hosts a game and I refresh the server list - it is empty again BUT I can see his public IP address in a packet that the masterserver sends to my computer. I'm just about to build a VMWare machine that I'll stick directly onto the internet without any NAT at all - if that one fails as well there must be an issue with what the masterserver returns I guess.
     
    Last edited: Sep 8, 2011
  47. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    712
    Hey guys,

    I am trying to submit a game to contest by the end of this month, is anybody interested in setting up some basic multiplayer for our game? LAN or WAN is fine, we just have not had any luck finding a network programmer thus far. Any help would be appreciated.
     
  48. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    I've now also tried the Example2 on a freshly installed WindowsXP machine directly connected to the internet with a public IP and no NAT. I first ran the Web version as a server host on that computer and my machine (which is behind NAT) as a client. My client still has the message "No servers running right now" in the Join screen.

    I also ran a second web instance on the public unNATed XP machine to click Join, but that reports the same "No servers running right now."

    Not overly impressed by the success rate of this to be honest, argh. Is Masterserver really a viable option at all?

    I'm considering whether it would be an option to have Unity do a HTTP post to a PHP script when someone launches a server. The PHP script would take the server details, store them in a database, and publish the servers online. Clients would then do a HTTP request to that web server and receive a server list as HTTP instead, and then direct IP connect would be utilized instead. This means that those who want to host a server would have to port forward their server port in their firewall - but to be honest that would be so much simpler than trying to troubleshoot NAT traversal problems.

    Also, can someone who has previously confirmed the examples of "Ultimate Unity Networking" to be working please try them out again? Maybe there really is a problem with the Unity masterserver?
     
  49. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    imphy: How frustrating! Atm this does look like a Unity client/masterserver bug. But it's weird that youhaven't seen ANY games pop up yet(?).
    I used UN + masterclient extensively in Cubelands and it worked quite OK there (i did also keep a http list of servers to be able to show a list on the website, not due to connectivity reasons).
     
  50. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    Leepo: yes, it's a time and motivation drainer at the moment =) Still no games have popped up. No I'm debating whether to leave it all alone for a few days, focus on the game development instead, and revisit this in case it's a temporary masterserver issue. Another alternative would be to try and set up my own masterserver, or look at Photon maybe.

    It would still be much appreciated if someone can confirm whether or not they are experiencing the same issues with the masterserver side of things from the tutorial at the moment.
     
    Last edited: Sep 9, 2011