Search Unity

Feedback needed! New Doc for Getting Started with Unity Multiplayer

Discussion in 'Multiplayer' started by Erik-Juhl, Nov 19, 2015.

  1. jroto23

    jroto23

    Joined:
    Oct 19, 2015
    Posts:
    82

    Thanks!
     
    isidro02139 likes this.
  2. jroto23

    jroto23

    Joined:
    Oct 19, 2015
    Posts:
    82
    Bump...
    Hopefully he reads this and can give us a time frame / status

    @Erik Juhl
     
    isidro02139 likes this.
  3. DSebJ

    DSebJ

    Joined:
    Mar 30, 2013
    Posts:
    101
    The doc is really good - wish I had found this before I started :)
     
  4. foxvalleysoccer

    foxvalleysoccer

    Joined:
    May 11, 2015
    Posts:
    108
    How do i get this set up to play on two different computers? Right now it works if i open two browsers on the same PC. But when I put it on my server and test on two different computers it does not network. What piece am I missing?
     
  5. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    External IP, or use Unity MatchMaking service.
     
  6. foxvalleysoccer

    foxvalleysoccer

    Joined:
    May 11, 2015
    Posts:
    108
    Is there a tutorial that you know of that does this?
    I have a server. If i change the network address from local host to the server ip address will it work?
     
  7. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    That's is where you enter in your external IP address, or your DNS domain. localhost is a domain name with the IP address of value, 127.0.0.1.

    If you are thinking in where to put the IP address other than the text field, where else would you put it?
     
  8. foxvalleysoccer

    foxvalleysoccer

    Joined:
    May 11, 2015
    Posts:
    108
    I got the ip of my server and put it in the network address in the network manager. I changed the port to 80. Its not working. Do I need to keep the port to 7777? What else might I be missing?
     
  9. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Use a port that you know for sure will be open. I found issues when using 7777 in Canada.
     
  10. logon_13

    logon_13

    Joined:
    Dec 29, 2015
    Posts:
    2
    This is great but I have an important question about UNET.

    I'm using Unity 5.3.2f1 and I'm finding the method OnServerStart() is only being called the first time im click host. If I shut down the server without closing it and click host again OnServerStart() is not being called. To me this is unexpected behavior

    Thanks in advance to anyone who replies
     
  11. logon_13

    logon_13

    Joined:
    Dec 29, 2015
    Posts:
    2
    Interesting I should probably post a bug report. I fixed it by having an offline scene and an online scene
     
  12. PsychoDuckArcade

    PsychoDuckArcade

    Joined:
    Jun 17, 2014
    Posts:
    21
    Could we get a version for a dedicated server instead of a player host?
     
  13. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Make a Unity Feedback instead of here.
     
  14. Erik-Juhl

    Erik-Juhl

    Unity Technologies

    Joined:
    Jul 11, 2012
    Posts:
    59
    Hey! Thanks for all the feedback. The "official" version is now part of the online docs with the rest of UNet:
    http://docs.unity3d.com/Manual/UNetSetup.html

    I see a few questions about when we would add more to it. For that I'd like to hear what you all think we should do next. We originally had placeholders for match maker and relay server but went into more game play stuff instead. Should we continue with match maker and relay server or are there more game play related things you all would prefer to see?
     
  15. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Personally more game play related stuff. Also replace that old gui hud, it's disturbing.

    I'm unsure of the more game play related stuff as of now because I have not tested all the current game play related stuff you currently have implemented.

    Is there a list where I can go over them?

    Thanks
     
  16. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    The first thing I would suggest you all to do is to create a new sticky thread to clean up all the clutter of posts no longer relevant towards getting the feedback you wished to hear from (since your "official" doc is out, it would be better to stick to the most up-to-date info.)
     
    pKallv likes this.
  17. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Personally, I would like to see the docs getting improved especially on those parts which still have the most crucial open gaps. I think it would be nice to have enough documentation available in order to enable people to create production ready multiplayer games. In many cases this would also include matchmaking and relay server. In addition, I would like to suggest to work on connecting the UNET documentations with the real project examples in the forum. I think it is important to keep those examples up-to-date so that they work without errors and that they are sufficiently documented.

    Maybe it would be a good idea to create a public list somewhere in the forum which collects all open ToDo's for improving UNET and its docs so that people can see what you are currently working on. This way people can provide feedback on priorities for the open points. Moreover, if people notice that something important is not included in that list, they can point you to a respective improvement measure. The keyword is transparency and I think it would help the community to help you, the Unity devs, to improve UNET and the docs with keeping a focus on the right things.
     
    Last edited: Feb 19, 2016
  18. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    I looked at it and from the start there is a problem: No explanation for what is a client or host! I feel there needs to be both VERY technical stuff in the docs AND very EASY stuff in the docs. However I find this video does a great job of explaining the beginning of uNet:

    Also the docs need to have better description for the components (such as the Network Transform).

    Everything else seems good!
     
    Last edited: Feb 25, 2016
  19. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    We actually expected you to have this article read already.
     
  20. Red_Kay

    Red_Kay

    Joined:
    Aug 14, 2015
    Posts:
    94
    I really need help at learning LLAPI can any1 gimme a link to where to start. And please don't give Unity's manual it sucks. I tried and did not understand anything.
     
  21. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Make a new thread and ask about what you don't understand in chunks/portions, so we can teach you about it.
     
  22. Red_Kay

    Red_Kay

    Joined:
    Aug 14, 2015
    Posts:
    94
  23. Red_Kay

    Red_Kay

    Joined:
    Aug 14, 2015
    Posts:
    94
    Please make UNET LLAPI tutorial!
     
  24. Deleted User

    Deleted User

    Guest

    Hi @Erik Juhl, thank you so much for this. I've been using UNet a while but will still go through this to make sure my basics are solid. Nowhere in the official version does it mention adding DontDestroyOnLoad() in a script somewhere on the player object. I've found this is necessary so that the player isn't destroyed when calling NetworkManager.ServerChangeScene().

    Could you let us know if adding DontDestroyOnLoad() in this way is correct?
     
  25. PhilippG

    PhilippG

    Joined:
    Jan 7, 2014
    Posts:
    257
    Concerns with bullet replication

    I was recently working on replicating bullets and I followed you example, but when testing, I started to have some concerns and its quite obvious.
    If you are the host, there is no problem at all. I press fire and bullets spray immediatly.
    But if I am a remote client, and I send my request to spawn a bullet out to the server, there might be significant latency between me pressing the button and actually see my bullet flying. Every player would instantly complain if bullets appear late.
    This is why I'd suggest the player should instantiate the bullet immediatly and do the replication for the other clients afterwards.
    I'm just not sure about how to do this the cheapest and most reliable way possible. I currenty call a [Command] method that calls a [ClientRpc] with arguments (string prefab, Vector3 position, Quaternion rotation) so I can instantiate it on the other clients with resources load (with a !isLocalPlayer check) . This means the bullet has no network identity and it lives independently on all clients. Only either the server or the instigating player should deal damage of course.
     
    Wattosan and Deleted User like this.
  26. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Hi.
    I did some major changes on my project, partly taken from this documentation and I have a question.
    Regarding the following code, I can't really see what I'm missing or am I doing it completely wrong?

    Code (CSharp):
    1.                        if (Input.GetKeyDown (KeyCode.Q)) {
    2.                 CmdSetNewPrimary ("Sten Gun");
    3.             }
    4.         }
    5.     }
    6.  
    7.  
    8.     [Command]
    9.     public void CmdSetNewPrimary(string newPrimary){
    10.         RpcSetNewPrimary();
    11.     }
    12.  
    13.     [ClientRpc]
    14.     public void RpcSetNewPrimary(){
    15.          //What did I do wrong over here?
    16.         wpPrimaryCurrent = newPrimary;
    17.     }
     
  27. Deleted User

    Deleted User

    Guest

    you need to pass newPrimary to RpcSetNewPrimary().
     
    Wattosan likes this.
  28. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    It doesn't seem to work. Am I doing anything stupid? See the following code:
    Code (CSharp):
    1. [Command]
    2.     public void CmdSetNewPrimary(string newPrimary){
    3.         RpcSetNewPrimary(newPrimary);
    4.     }
    5.  
    6.     [ClientRpc]
    7.     public void RpcSetNewPrimary(){
    8.         wpPrimaryCurrent = newPrimary;
    9.     }
     
  29. Deleted User

    Deleted User

    Guest

    Your RpcSetNewPrimary() should look like this:

    Code (CSharp):
    1. [ClientRpc]
    2. public void RpcSetNewPrimary(string newPrimary){
    3.         wpPrimaryCurrent = newPrimary;
    4.     }
     
    Justice0Juic3 likes this.
  30. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Thanks man. :rolleyes: This will save me a lot of time instead of having to invoke a seperate Command and RPC everytime.
    ...Because there's going to be about 50 choosable Primary weapons in the game. :p

    Cheers!
     
  31. Deleted User

    Deleted User

    Guest

    Sounds like I might need to clarify in case we're not on the same page. You'll still have to call the Command that then calls the RPC. The RPC just needs to receive the parameter. i.e.

    Code (CSharp):
    1. [Command]
    2. public void CmdSetNewPrimary(string newPrimary){
    3.     RpcSetNewPrimary(newPrimary);
    4. }
    5. [ClientRpc]
    6. public void RpcSetNewPrimary(string newPrimary){ // <--- this parameter
    7.     wpPrimaryCurrent = newPrimary;
    8. }
     
  32. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    No need to clarify, I understood your previous quote already.
     
  33. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Started on the web-documentation for matchmaking and I think it works pretty well. On the other hand, the explanation of the NetworkTransport API is very low and needs a lot of working. It's minimal on the documentation and example code and the code listed is in Java instead of C# :(
     
  34. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    You should report that in the Documentations subforum.
     
  35. Somaweb

    Somaweb

    Joined:
    Feb 4, 2015
    Posts:
    14
    It would be also nice, to have an example how to correctly leave a game and a "lobby"
     
    MrLucid72 likes this.
  36. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    Hi @Erik-Juhl -- Great job -- Few things that I would 100% emphasize:

    1. The lobby and lobby scripts. The current ones out there are very vague, details regarding staging are non-existent, and matchmaking docs are extremely sparse (and include syntax errors for the lobby callbacks - docs seem to be missing an import statement of some kind).

    There's also not much flow -- I found a sample Unity project with awesome flow for basic networking, but it doesn't even include an editor LobbyManager Component -- it was all old API code.

    LobbyManager docs are also very sparse and with no flow in regards to using it with other lobby feats.

    Please add more consistent/detailed docs with more examples for the lobby and all that relates to the lobby - esp staging and matchmaking (+MM with friends) - and Show a general flow of events (Quickstart) for your most basic lobby setup.

    2. Host Migration workaround. This feature is confirmed as a reproduced bug since June and has not been fixed yet - as this is a major feature, please post a workaround as it's been quite a long time while not yet fixed.

    3. [Added 11/23/2016] Add docs/examples for NetworkLobbyManagerComponent's "Show Lobby GUI" (EDIT: Found Here on BitBucket - still needs API doc update)

    Thank you.
     
    Last edited: Nov 23, 2016
    foobar, isidro02139 and kortenoever like this.
  37. kira419

    kira419

    Joined:
    Dec 16, 2016
    Posts:
    3
    New Game Guide: 24 pages with pictures.
    New Lobby Guide: 1/4 page sad summary.


    Current Game Guide: 18 sections with pictures.


    Current Lobby Guide: 15-bullet summary. Less bullets than pages. What about callbacks? What about replacing the OnGUI (which is 50% of the effort)? What about handling common events? How do I get what info from where, and when & where do I do it?



    I find replacing the OnGUI events harder than anything, but there's no guide. I thought it seems pretty important, hm?

    There are already game guides. How about a lobby guide focus? It's the only one missing and it's confusing.
     
    Last edited: Dec 17, 2016
    MrLucid72 and theANMATOR2b like this.
  38. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    This is where I'm at :) They have a bitbucket for NetworkHUD, which helps, but it's dated and doesn't use HLAPI, so it doesn't really help with much since you don't know what callback to call and where. Out of the 30ish new callbacks - it's hard to tell where to put what, like you said, since onGUI uses the old stuff/non-HLAPI.

    However, there's no bitbucket that I could find for the LobbyGUI. Anyone know where this is? It shows player list added/sync'd, ready up/down button, exit and enter lobby buttons. This would be a great reference (even though it's likely dated, too) if I can find it ! I tried asking a few weeks ago, but no response. Which leads me to another suggestion:

    While the docs are being updated, especially HLAPI/Lobby/UNET/HostMigration/MatchMaker (where there are no updated docs/demos), please add some staff to answer questions in the mplayer forum! We NEED you!
     
    Artaani and isidro02139 like this.
  39. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    Wait a second.... I just realized the doc revamp draft was posted OVER 1 YEAR AGO! *facepalm*

    This entire mplayer forum is completely abandoned by staff about 1.5 years ago. No staff will even challenge these words.
     
    Last edited: Mar 1, 2017
    Artaani likes this.
  40. Jtoomer

    Jtoomer

    Joined:
    Jan 30, 2017
    Posts:
    38
    I had been having some trouble getting multiplayer to work and the document went a long way to helping out with that. Any sort of updated tutorial on the topic is a good thing in my opinion.
     
    theANMATOR2b likes this.
  41. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Hi
    Just trying this networking tutorial - https://docs.unity3d.com/Manual/UNetSetup.html and when I press play in the editor when the build is running (and hosting) then the build closes and nothing happens in the play window. If I leave both LocalPlayerAuthority and ServerOnly false (on the NetworkIdentity component) and build then the build window stays open and I can join as client from the editor (play mode). In this case both cubes move but only in the one window (is this correct?)

    Then, moving to the next step, and changing the code so only the local cube moves then the build window closes when pressing play in the editor no matter what the other settings are. Please help. Thank you.
     
    rogueknight likes this.
  42. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Just figured out quite a nice flawed... "Registered Spawnable Prefab"? Does that mean the game need to have ALL enemies, spells, projectile, etc, loaded in that Manager to be usable??
     
  43. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
  44. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Well... that's great no-go for us. Can't load Gb of stuff all the time.
     
  45. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    It wont load it. It will reference it.
     
  46. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    In Unity, a reference is always loaded. Unity has no weak reference mechanism.
     
  47. GameDaddy

    GameDaddy

    Joined:
    Oct 23, 2011
    Posts:
    9
    I'm running this today in 2018.1 using the script from the Unity 5.3 Tutorial instead of this one here, and when I select the player prefab and create the c# PlayerController script the script is not automatically being attached to the prefab, or childed, or anything. It took me awhile to figure out that I needed to manually attach the script to the prefab by dragging it onto the prefab. Then, and only then, is the tutorial running correctly once the LAN Host is started up.

    Link to the 5.3 Tutorial
    https://unity3d.com/learn/tutorials...ion-simple-multiplayer-example?playlist=29690
     
    Last edited: May 14, 2018
  48. GameDaddy

    GameDaddy

    Joined:
    Oct 23, 2011
    Posts:
    9
    @CarlUnity
    Hi Carl, Now I'm getting compiler problems when running the tutorial code. Do you know who happens to be working at Unity on Tutorials right now that i could get in touch with to work through the issues with the latest tutorial?

    Ty!
     

    Attached Files:

  49. mayo_f

    mayo_f

    Joined:
    Apr 24, 2017
    Posts:
    8
    Try with;
    Code (CSharp):
    1. GetComponent<Renderer>().material.color = Color.blue;
     
  50. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Like others have said, format the code, everything else is clear, well laid out and, damn boy, networking has become a whole lot easier since 2013!

    I'd like to see an example that synch a BT or a state machine for NPC and inventory sync, to show us how other data types get handled.
     
    Last edited: Jul 27, 2018