Search Unity

Unity Multiplayer Mirror - Networking for Unity (UNET Replacement)

Discussion in 'Connected Games' started by vis2k, Aug 11, 2016.

  1. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,122
    Ye that's ~130 lines. The rest is line changes, not removals, empty lines, comments and such.

    Even then it's generous as code attributes, and enum declarations which are not logic are counted.

    Only reason I'm saying it is because it's the metric you used to justify and argue a feature change which someone was unhappy with.
     
    Last edited: Mar 7, 2019
    Vincenzo likes this.
  2. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Ok, thanks for counting.
     
  3. Vencarii

    Vencarii

    Joined:
    May 19, 2016
    Posts:
    9
    The code below the stack trace is on the Player object. The object that is requested and is the reason for the NullReferenceException is MasterList, a non-player GameObject that has "Server only" checked in the NetworkIdentity.
    Here is the full stack trace from the output_log.txt:

    NullReferenceException: Object reference not set to an instance of an object
    at Player.CmdGetRandomData (System.Int32 count, System.String reason) [0x0000c] in D:\Unity\Projects\MyGame\Assets\Scripts\Player.cs:127
    at Player.CallCmdGetRandomData (System.Int32 count, System.String reason) [0x0000b] in <860fb0ddc13e4b6f9ecc7c13c1e9ec71>:0
    at Player.OnStartLocalPlayer () [0x00024] in D:\Unity\Projects\MyGame\Assets\Scripts\Player.cs:44
    at Mirror.NetworkIdentity.SetLocalPlayer () [0x00032] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkIdentity.cs:596
    at Mirror.NetworkServer.SetupLocalPlayerForConnection (Mirror.NetworkConnection conn, Mirror.NetworkIdentity identity) [0x00093] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkServer.cs:570
    at Mirror.NetworkServer.InternalAddPlayerForConnection (Mirror.NetworkConnection conn, UnityEngine.GameObject playerGameObject) [0x0006d] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkServer.cs:529
    at Mirror.NetworkServer.AddPlayerForConnection (Mirror.NetworkConnection conn, UnityEngine.GameObject player) [0x00001] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkServer.cs:502
    at Mirror.NetworkManager.OnServerAddPlayerInternal (Mirror.NetworkConnection conn) [0x000a4] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkManager.cs:704
    at Mirror.NetworkManager.OnServerAddPlayer (Mirror.NetworkConnection conn) [0x00001] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkManager.cs:676
    at Mirror.NetworkManager.OnServerAddPlayerMessageInternal (Mirror.NetworkMessage netMsg) [0x00075] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkManager.cs:568
    at Mirror.NetworkConnection.InvokeHandler (System.Int16 msgType, Mirror.NetworkReader reader) [0x00036] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkConnection.cs:206
    at Mirror.NetworkConnection.TransportReceive (System.Byte[] buffer) [0x000db] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkConnection.cs:241
    at Mirror.ULocalConnectionToServer.SendBytes (System.Byte[] bytes, System.Int32 channelId) [0x0001a] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\LocalConnections.cs:41
    at Mirror.NetworkConnection.Send (System.Int16 msgType, Mirror.MessageBase msg, System.Int32 channelId) [0x0000a] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkConnection.cs:132
    at Mirror.ClientScene.AddPlayer (Mirror.NetworkConnection readyConn, Mirror.MessageBase extraMessage) [0x000b4] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\ClientScene.cs:97
    at Mirror.ClientScene.AddPlayer (Mirror.NetworkConnection readyConn) [0x00000] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\ClientScene.cs:63
    at Mirror.ClientScene.AddPlayer () [0x00000] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\ClientScene.cs:60
    at Mirror.NetworkManager.OnClientConnect (Mirror.NetworkConnection conn) [0x00021] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkManager.cs:758
    at Mirror.NetworkManager.OnClientConnectInternal (Mirror.NetworkMessage netMsg) [0x00060] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkManager.cs:601
    at Mirror.NetworkConnection.InvokeHandler (System.Int16 msgType, Mirror.NetworkReader reader) [0x00036] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkConnection.cs:206
    at Mirror.NetworkConnection.TransportReceive (System.Byte[] buffer) [0x000db] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkConnection.cs:241
    at Mirror.NetworkClient.OnDataReceived (System.Byte[] data) [0x0000f] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkClient.cs:98
    at Mirror.LocalClient.Update () [0x00010] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\LocalClient.cs:43
    at Mirror.NetworkClient.UpdateClient () [0x00001] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkClient.cs:281
    at Mirror.NetworkManager.LateUpdate () [0x00007] in D:\Unity\Projects\MyGame\Assets\Mirror\Runtime\NetworkManager.cs:152

    (Filename: <860fb0ddc13e4b6f9ecc7c13c1e9ec71> Line: 0)

    And the corresponding code is this. (line 127 is "if (masterList.AllDataList.Count == 0) {")

    Code (CSharp):
    1. [Command]
    2.     void CmdGetRandomData(int count, string reason)
    3.     {
    4.         masterList = FindObjectOfType<MasterList>();
    5.  
    6.         if (masterList.AllDataList.Count == 0) {
    7.             masterList.LoadDataAtGameStart();
    8.         }
    9.  
    10.         string dataString = masterList.GetRandomDataIdsForRpcCall(count);
    11.  
    12.         TargetReceiveData(connectionToClient, dataString, reason);
    13.     }
     
  4. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    If masterList.AllDataList.Count throws a NullReferenceException then probably a part of that is null?
    If server-only is checked then the object won't exist on the client by the way.
     
  5. Vencarii

    Vencarii

    Joined:
    May 19, 2016
    Posts:
    9
    Okay fair enough. So I changed MasterList and didn't check any box in NetworkIdentity.
    It then works as expected when I run the Host in the Unity Editor and connect to that with a Standalone Client.
    But when I start the Standalone Build as Host, I get the NullReferenceException. :\ Any ideas about that?

    (masterList is null in that case, but I don't know why. Client works as Standalone, Host doesn't)
     
    Last edited: Mar 7, 2019
  6. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    upload_2019-3-8_20-57-48.png

    Update:
    very happy to announce that the Persistent SceneId fix is live [ https://github.com/vis2k/Mirror/pull/563 ].

    This bug caused me tremendous amounts of pain during the last three years. In fact, I was the one who originally reported it to the UNET team back then.

    Original UNET used FindObjectsOfType<NetworkIdentity> to assign sceneIds with a simple counter. The problem was that the FindObjectsOfType order was not deterministic. In other words, the result was often scrambled. So when building a game and connecting to it with the Editor, everything worked fine until we restarted the Editor and got a completely different FindObjectsOfType order, at which point the Editor and the Build would get out of sync. This resulted in situations where sometimes a player's move on the server would actually move a monster on the client, which is a complete nightmare to deal with.

    Later on when starting HLAPI Community Edition, we found a workaround where FindObjectsOfType was sorted by the actual order in the Hierarchy (by the sibling path to be exact). This worked perfectly fine for one scene, and in fact the UNET team even ported the fix to UNET. Instead of using the sibling path, they used only the root index though, which would still result in the same type of errors if the scene object was a child object of something else.

    Eventually people started switching scenes at runtime, which exposed a flaw in my original fix. When loading a scene for the second time, it's possible (in fact, likely) that objects like the NetworkManager were moved into the DontDestroyOnLoad scene, hence offseting the sibling path by -1 and getting the client and the server out of sync again.

    The next approach was to use Unity's fileID. Unity stores a fileID value for each object and each component in the Scene. It's persistent across restarts, and can be found in the Scene.unity files. The fileID itself is not directly available in Unity. There is however a workaround where a script is used to set the Inspector to debug view, at which point the LocalIdentifierInFile could be read. This was the perfect solution, except that it didn't work all the time. the LocalIdentifierInFile is sometimes 0 if Play wasn't pressed yet, and it even changes at runtime occasionally. There is no documentation on this field either, but it seems like this is not the true fileID at all times, only sometimes.

    The final solution was to generate a random sceneID of the format 0x00FFFFFF in Edit time, whenever OnValidate is called. Generating the sceneID sets the scene as dirty, which adds a '*' behind the scene name to indicate the user that it needs to be resaved. In other words, each NetworkIdentity gets a random sceneID that is stored on disk and never changed again afterwards.

    This alone was not enough yet though. If a user duplicates SceneA.unity to SceneB.unity, then ObjectA from SceneA will have the same sceneID as ObjectA in SceneB. This second problem was solved by shifting the scene's build index into the SceneID when the scene is first loaded. The previous sceneId of 0x00FFFFFF would then change to 0x01FFFFFF for the scene at index = 1. As result, we get a unique sceneId that even works if the user duplicates a scene.

    The third critical problem were unopened scenes. A lot of people will upgrade to the latest Mirror version for the fix, and there is a small chance that a user with SceneA and SceneB might only open SceneA, get all sceneIDs for SceneA assigned and then build the project without ever actually opening SceneB again, leaving all the SceneB sceneIDs still empty. In that case, Unity would call OnValidate for each object in SceneB, Mirror would generate a sceneID, but the scene would never get saved because the modifications happened at build time. This issue would not affect new Mirror users (because they always opened each of their new scenes with the latest Mirror version), but even if we were to add a huge "PLEASE RESAVE ALL SCENES ONCE" warning, someone upgrading to the latest Mirror version would still miss it and run into strange missing sceneID errors.

    This third problem was solved by a simple isBuilding check to never assign sceneIDs in OnValidate. Instead, users with yet unopened scenes will receive an Error message that even cancels the build process, notifying them to resave the unopened scene once.

    In the end, we get perfectly persistent sceneIds that work across multiple scenes in (so far) all possible scenarios. This fix will allow you to implemented advanced features like zones, instanced dungeons, player housing and (possibly) additive scene loading.

    I believe this was the last critical bug in Mirror. Enjoy!
     
    Last edited: Mar 8, 2019
    Player7, LostPanda and hopeful like this.
  7. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    677
    you don't have to duplicate anything. for example:

    Code (CSharp):
    1. abstract class MyMessageHeader : MessageBase
    2. {
    3.       int foo;
    4.       string bar;
    5.      // whatever is common with all your messages
    6. }
    7.  
    8. class MyMessage1 : MyMessageHeader {};
    9.  
    10. class MyMessage2 : MyMessageHeader {};
    11.  
    12. class MyMessage3 : MyMessageHeader {};
    13.  
    Another cool thing with this change is that once we remove the old api, we can even start converting some of the messages to value types, and eliminate those allocations. But the old API needs to die for that.
     
    Last edited: Mar 9, 2019
    antsonthetree and vis2k like this.
  8. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    52
    Thanks - yup I found the workaround for duplicates in your source. Very helpful. So far all is working fine and it does not suck as much as I thought it would. :)
     
    goldbug and vis2k like this.
  9. MwGfyzzo

    MwGfyzzo

    Joined:
    Jul 10, 2018
    Posts:
    7
    Your Migration Link in the First Post isn't working - you should fix that.

    Thanks for the free Network HLAPI. The new Unity Documentation around Networking is a mess. So I'm glad someone did the work to provide what Unity is lacking.

    edit: I got errors because of some old C# version or something. I used the recommended option to just change the target version or so and after that messed with the player settings maybe a bit too much because I thought it has to do something with that... Can someone tell me what the recommended player settings for Scripting Runtime Version and API Compatibility Level are?
     
    Last edited: Mar 13, 2019
    hopeful likes this.
  10. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Use Unity 2018.3.6 with .NET 4.X
     
  11. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    173
    It looks reaaally good.

    Only two decisive questions for me:
    - Is WebGL supported?
    - Anything to work with channels? Something to work with rooms or regions in the same server.

    Thanks in advance ;)
     
  12. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    677
    Yes, WebGL works great. You can use the WebsocketTransport, or you can use MultiplexTransport if you want your server to support both webgl and standalone clients. We are considering making the MultiplexTransport the default.

    Channels work with [Command], and [*Rpc]. But you need to use a transport that take advantage of channels such as litenetlib, ignorance or steam. Channels don't really do anything with websocketransport, because there is no way to have unreliable messages in websockets. Join our discord server to get help on those other transports.

    To work with rooms or regions, we have interest management, you can easily write your logic of who can see whom, and have people divided by room/region.
     
  13. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Important: if you downloaded Mirror from Github after 2019-03-08 (persistent sceneids), then please redownload. There was a bug where sceneIDs would get out of sync if the scene was not added to build settings, because in that case Unity's gameObject.scene.buildIndex would be '-1' when building, but '0' when pressing Play in the Editor.
     
    Last edited: Mar 14, 2019
  14. MwGfyzzo

    MwGfyzzo

    Joined:
    Jul 10, 2018
    Posts:
    7
    I didn't ask the Unity version :D So just to be sure:
    So ".NET 4.x Equivalent" as Scripting Runtme Version
    and ".NET 4.x" as Api Compatibility Level ?

    I also have some other basic questions now. Since I built a small Lobby UI I think I want to use the Network Lobby Manager. I'm not really sure how I use it with my own UI. Do I have to derive from the Network Lobby Manager? I skimmed through your code and I don't really know which methods I would need to override and what original functionality I should re-implement in overridden methods. I certainly need a way to catch events like when clients connect or set themselves ready and so on to refresh my own lobby.

    I assume another alternative would be to just use NetworkServer and Clients and do everything manually? Though I don't know if that's a smart thing. But I don't even know yet what I'm loosing if I did.
     
  15. MCoburn

    MCoburn

    Joined:
    Feb 27, 2014
    Posts:
    67
    Unless you have issues or asset that cannot work with NET Standard 2.0, I recommend using:

    At least 2018.3.6 (preferably .7 since that fixes the remote code execution bug)
    Scripting Runtime: NET 4.x Equivalent
    API Compatibility Level: NET Standard 2.0

    The reason I suggest NET Standard is that it's lighter and doesn't have all the baggage of a full NET 4.x runtime. Some plugins may not work, but for my shooter game I've had no incompatibilities with NET Standard 2.0 (yet).

    Also I believe that Mirror should come with a network lobby demo scene? I think I saw it in the git version, haven't checked the AS packaged version.
     
  16. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    294
    Using Unity 2018.3.6+ defaults to .NET 4.x Equivalent" as Scripting Runtime Version and ".NET 4.x" as Api Compatibility Level so that's why he said that. Yes you need to use those or .Net Standard 2.0 as MCoburn said.

    There is a complete example included in the Examples/Lobby folder that demonstrates what you need to do for your custom Lobby layout. If you still need help, drop by our Discord anytime.
     
  17. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    173
    Is the Asset Store version the right one?
     
  18. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Asset Store version is fine.
     
  19. MwGfyzzo

    MwGfyzzo

    Joined:
    Jul 10, 2018
    Posts:
    7
    Thanks everyone for the answers!
    I looked yesterday into one example that uses the NetworkLobbyManager, but it used the Standard NetworkHUD thingy. That's also a reason why I made that post. I didn't know there is one with a custom one, but I will look into it. Maybe I will visit your discord as well if I have more issues.

    edit: There are 4 examples in the Asset. None of them use a custom UI. All of them use the NetworkManagerHUD.
     
    Last edited: Mar 14, 2019
  20. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    294
    Just so no one reading this thinks this went ignored, support was handled in Discord.
     
    MwGfyzzo and vis2k like this.
  21. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Made with Mirror: SamuTale by Royall in our Discord.
     
  22. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    9
    Hi guys,

    I've just started using Mirror and I'm wondering: how do you usually test/debug multiplayer games in Unity? My game will be client-server so I need at least one client and one server running to test the game.

    I've searched the web, but it seems most (all?) solutions aren't working with the latest version(s) of Unity. The workaround to all of this seems to be etiher to:
    • Copy/paste the entire project and run two Unity instances
    • Build the game and run one instance with the build and the other instance you want to debug with Unity/VS

    Also, as the code of the server and the client is shared, how do you pass the information of "you are the server" to the server build (I'm talking about File > Build Settings... > Server build) to basically call NetworkManager.StartServer() instead of NetworkManager.StartClient()?

    Thanks for the great work and the support!
     
  23. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Progress: fixed some bugs in the Pong demo, and added a new Tanks demo:
    upload_2019-3-17_21-49-59.png

    Build & Run it, start server (or host) in build and connect to it as client from Editor (or vice versa)
     
    GuiTeK likes this.
  24. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    9
    Thank you @vis2k !

    I have another question. While my game is actually working (= the client connects to the server successfully and displays the "Online Scene"), the client prints an error message when it connects to the server: "A connection has already been set as ready. There can only be one." This error comes from Mirror/Runtime/ClientScene.cs:Ready:121.

    What my Unity project looks like:
    • Two scenes: one named "LoginScene", one named "GameScene"
    • A
      NetworkManager
      object with a
      NetworkManager
      script inherited from
      Mirror.NetworkManager
      , it is exactly this one: https://vis2k.github.io/Mirror/Concepts/Authentication
    • The NetworkManager has "Offline Scene" = LoginScene and "Online Scene" = GameScene
    • The NetworkManager doesn't have a "Player Prefab"

    I read the relevant Mirror code and it seems pretty "normal" that this error message will be printed everytime:
    1. When the client connects to the server,
      OnClientConnect()
      is called, which in turn calls
      ClientScene.Ready()
    2. When the client has successfully connected to the server,
      OnClientSceneChanged()
      is called, which in turn also calls
      ClientScene.Ready()
      , thus producing the error message
    Did I miss something? Is there a mistake in Mirror's code?
     
  25. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Please open an issue on github and let us know exactly how to reproduce it :)
     
  26. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Our new website https://mirror-networking.com is now live!
    * All important links (Github, Asset Store, Transports, Discord, ...)
    * Great showcase of projects! We are insanely happy by what you guys accomplished with Mirror!
    * Prepares for additional tools & services like List Server, etc.
     
  27. i16yue

    i16yue

    Joined:
    Aug 2, 2015
    Posts:
    2
    May I use mirror in the unity 5.6. I tried the 2018.3.9 but the unity has other bugs in my project.
     
  28. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    We need Net 4.X for websockets and some other features, there is no good way to use 5.6, sorry
     
  29. Robotron18

    Robotron18

    Joined:
    Aug 15, 2010
    Posts:
    12
    Hello, friends. I'd like to use Mirror for mobile game concept. I need to quickly place List Server on my VDS server.

    You can even host your own Game Server (with the ListServer scene) and have it appear in the list server.

    For documentation of this is not enough. What should I do to get quick support and results?
     
  30. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    How quick do you need it?
    We are about to release it here: https://mirror-networking.com/list-server/ as soon as possible. Setting up a payment system first.
     
  31. Robotron18

    Robotron18

    Joined:
    Aug 15, 2010
    Posts:
    12
    After two weeks. Maybe Paypal?
     
  32. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Two weeks is doable.
    Check out our discord for news if you want.
     
  33. Robotron18

    Robotron18

    Joined:
    Aug 15, 2010
    Posts:
    12
    I learned everything, this is what I need. I will wait for the price. Thanks.
     
    vis2k likes this.
  34. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Spawning Improvement/Fix: Previously when a client joined the world, observers wouldn't be spawned until next ProximityChecker rebuild in most cases. With this change, spawning should happen immediately. This should make for a more seamless user experience when entering the game world.

    Done.
     
  35. Dareheim

    Dareheim

    Joined:
    Oct 12, 2013
    Posts:
    6
    $ 30 - wow!
     
  36. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    tobiass likes this.
  37. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    9
    Thank you for the time and work you put in Mirror!

    I just found a new bug, I'd be glad to fix it if you tell me how you want to fix it (there are multiple ways to do it). https://github.com/vis2k/Mirror/issues/639
     
  38. i16yue

    i16yue

    Joined:
    Aug 2, 2015
    Posts:
    2
    Thanks for the excellent work for the Mirror!

    A small advice:
    In the NetworkManager:
    public bool startOnHeadless = true;
    The default true should be set to false, or just delete the function about start server codes in the Start ()
    First time I didn't know it. Everything is fine in the editor. But after I build the project and start in Headless mode. It started server automatically, then in my code initialize the project and get available port for the server and start the server again. And the ignorance loged that I have already start the server and with default port 7777. At the beginning, I thought it's a bug. Then I found the problem of start automatically on headless mode. So I think it should be changed.
     
    GuiTeK and vis2k like this.
  39. Le_Gringo

    Le_Gringo

    Joined:
    Jul 1, 2018
    Posts:
    6
    Hi Everyone,

    I would realize a little non-commercial project (for school purpose): i wanna create a game which could be played with 4 android mobile devices and a PC which will act as a central stage/monitor for all the player.

    To explain, every player should be able to give answer to a quizz displayed on the PC screen (example: Kowledge Is Power on PS4 with the PlayLink concept).

    I need some help to know where I am supposed to begin.(warning: I'm a big noob, i'm more a graphic designer than a real developer).

    Do you have any tutorial which will help me to make this with MIRROR?

    Thank you very much.
     
    Last edited: Apr 2, 2019
  40. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    Mirror has a documentation and several smaller, easy to understand example projects come with it.
     
  41. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,350
    Do the examples demonstrate all the features of Mirror?
     
  42. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    294
    All components are used in them, yes.
     
  43. TufanMeric

    TufanMeric

    Joined:
    Jan 1, 2015
    Posts:
    10
    I'm currently making a game and I need to decide between Mirror & Photon PUN2.

    I have a few questions:
    - Why should I use Mirror over Photon? How much $$ would that save me?
    - First post says server-client are one, how exactly does that work? Do I need to start the game on the server?
     
    Last edited: Apr 5, 2019
  44. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    677
    Mirror is free no matter how many users you have. However the cost of the framework is only a minuscule portion of the cost of making a game. Your biggest cost will be how much time it takes you to build the game. Pay attention at the features offered and what kind of game you will built, then pick the one that satisfies your needs.

    You have one single project. When you run it, you can decide if it is going to run as a server, client or both (host mode). In addition you can make a headless build and it will run as a server that clients can connect to.
     
    TufanMeric likes this.
  45. TufanMeric

    TufanMeric

    Joined:
    Jan 1, 2015
    Posts:
    10
    What if my game has a 1v1 game-mode? Do I have to start A LOT of server instances manually or is there anything that will do it for me?
     
  46. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    677
    making some assumptions here:
    You want 1v1 match making? everyone connects to the server, it matches you with someone and then you fight it out?

    You can certainly do it with Mirror, when someone connects you put them in the lobby, once matched, you make them as ready. The same server could be doing many matches at the same time.

    I believe PUN2 has that functionality out of the box. In my humble opinion the matchmaking will be easier in PUN2.

    What else do you need?
     
  47. TufanMeric

    TufanMeric

    Joined:
    Jan 1, 2015
    Posts:
    10
    I don't get this part, I already have Match Up asset which will do the matchmaking stuff for me, how can I possibly have multiple games running in a single mirror instance? That looks like a very hard thing to do using mirror. If you meant connecting users to each other, I have no idea how to open port programmatically for connections.
     
  48. veggiesama

    veggiesama

    Joined:
    Jul 11, 2017
    Posts:
    6
    I'm having trouble implementing a SyncDictionary. Could someone check out my thread here and see what's wrong? Between UNET documentation, Mirror documentation, and random forum posts, I can't figure out how to initialize the values of a SyncDictionary for clients.
     
  49. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    173
    I'm experimenting some jerky/strange behaviour, not sure if it's just one bug of the version or the websocket transport, but happens on every thing on the network:

    If I set an int SyncVar from 0 to 1, it appears to be 0 on some frames, making totally unrealiable/useless.
    Same happens for the network transform, it interpolates reaaally bad, like laggy. Same for the network animator.

    I'll try to post some gifs later.
     
  50. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,146
    feel free to open an issue on our github page with steps how to reproduce it