Search Unity

Showcase Mirror - Open Source Networking for Unity

Discussion in 'Multiplayer' started by mischa2k, Aug 11, 2016.

  1. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    Is the Asset Store version the right one?
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Asset Store version is fine.
     
  3. 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
  4. MrG

    MrG

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

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Made with Mirror: SamuTale by Royall in our Discord.
     
  6. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    12
    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!
     
  7. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    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.
  8. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    12
    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?
     
  9. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Please open an issue on github and let us know exactly how to reproduce it :)
     
  10. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    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.
     
  11. i16yue

    i16yue

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

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    We need Net 4.X for websockets and some other features, there is no good way to use 5.6, sorry
     
  13. 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?
     
  14. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    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.
     
  15. Robotron18

    Robotron18

    Joined:
    Aug 15, 2010
    Posts:
    12
    After two weeks. Maybe Paypal?
     
  16. mischa2k

    mischa2k

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

    Robotron18

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

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    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.
     
  19. Dareheim

    Dareheim

    Joined:
    Oct 12, 2013
    Posts:
    7
    $ 30 - wow!
     
  20. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    tobiass likes this.
  21. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    12
    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
     
  22. i16yue

    i16yue

    Joined:
    Aug 2, 2015
    Posts:
    4
    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 mischa2k like this.
  23. Le_Gringo

    Le_Gringo

    Joined:
    Jul 1, 2018
    Posts:
    7
    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
  24. mischa2k

    mischa2k

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

    Player7

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

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    All components are used in them, yes.
     
  27. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    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.
     
    tuf_dev likes this.
  28. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    767
    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?
     
  29. veggiesama

    veggiesama

    Joined:
    Jul 11, 2017
    Posts:
    7
    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.
     
  30. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    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.
     
  31. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    feel free to open an issue on our github page with steps how to reproduce it
     
  32. GuiTeK

    GuiTeK

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

    I continue to develop my game with Mirror, and I have a question about the usage of networked game objects, NetworkIdentity and authority.

    I'm trying to use only RPCs (and no network messages) as it seems it is the recommended way.

    What I want to achieve: call an RPC from the client to the server in a non-player GameObject.

    Here is what my game looks like:
    • LoginScene [Scene]
    • CharacterCreationScene [Scene]
      • CharacterCreationManager [Empty GameObject]
        • NetworkIdentity [Script Component] -- "Local Player Authority" is checked
        • CharacterCreationManager [Script Component]

    What works:
    1. CLIENT: LoginScene shows up, the user types their username/password and click "Login" button
    2. SERVER: checks the username/password in OnServerAddPlayer() and if they are correct, sends a SceneMessage("CharacterCreationScene") to the client
    3. CLIENT: CharacterCreationScene shows up, the user types their nickname and click "Create" button, C.F. below
    Code (CSharp):
    1. using Mirror;
    2. using UnityEngine;
    3. using UnityEngine.UI;
    4.  
    5. namespace Scripts.Scenes.CharacterCreationScene
    6. {
    7.     public class CharacterCreationManager : NetworkBehaviour
    8.     {
    9.         public InputField NicknameInputField;
    10.  
    11.  
    12.         public void OnCreateButtonClick()
    13.         {
    14.             NetworkIdentity networkIdentity = GetComponent<NetworkIdentity>();
    15.  
    16.             CmdCreateCharacter(networkIdentity, NicknameInputField.text);
    17.         }
    18.  
    19.         [Command]
    20.         private void CmdCreateCharacter(NetworkIdentity networkIdentity, string nickname)
    21.         {
    22.             Debug.Log($"Creating {nickname}...");
    23.         }
    24.     }
    25. }
    26.  
    However, when I click on the button, I get the following warning and the function isn't called on the server:
    Trying to send command for object without authority.

    So I have two questions:
    1. Why can't I call a RPC even if the "Local Player Authority" is checked on the NetworkIdentity component of the GameObject? How can I fix this problem?
    2. What would be the recommended way/pattern to do what I'm trying to do (if I'm not doing it the right way)?

    Thank you so much guys!
     
  33. krkim_unity

    krkim_unity

    Joined:
    Mar 30, 2018
    Posts:
    5
    Hi
    Mirrors are a great asset.
    I was really impressed with this asset. best!!
    I am trying to put a multi into a sandbox game using a mirror.
    However, I faced great difficulty.
    I was not good at synchronizing the world.
    The world is stored as a class type and is declared as a 2D array because it is a 2D world.
    However, when I read the documentation, I could not find a way to synchronize the class types.
    When you play a multiplayer game, you need advice on how to make the terrain the same.
    We need advice on how to efficiently synchronize class information.
    I am not a person living in an English-speaking country, so the question may be strange.
    Sorry, please understand.
    I will wait for your answer.
    thank!
     
  34. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    Short answer is: you don't. The correct pattern is to have all the code that communicates player actions / inputs on your player prefab. That means when you open a UI from your player you need to subscribe to the UI events in your player code.

    Stop by our Discord to get faster help.
     
  35. ScottPeal

    ScottPeal

    Joined:
    Jan 14, 2013
    Posts:
    61
    Has anyone gotten Mirror to run on 2019.2 alpha in a hybrid ECS mode?
     
  36. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Internal improvement: previously, UNET would send a spawn message for each entity, then afterwards one additional OwnerMessage to let the client know which of the entities is the local player. This was a huge bandwidth overhead (especially if it takes one extra TCP packet) and caused race conditions where isLocalPlayer may or may not be set in Start() already.

    We fixed it by storing the owner information in the spawn message directly. No more extra packet, no more extra code path, no more race condition.
    Nice find @goldbug

    We highly recommend using Unity 2018.4 LTS when it's released. Even 2018 isn't stable yet, I wouldn't bother with 2019 for a game server. It needs to be stable.
     
    SwiftIllusion likes this.
  37. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Cecil Update: the Weaver originally used Unity's older custom Unity.Cecil version to replace IL code for Rpcs/Cmds/Serialization.

    Today we upgraded it to the latest official Cecil 0.10.3 ( https://github.com/jbevain/cecil/ ) thanks to c6burns .

    This should give us several important bug fixes for the weaver, as well as peace of mind because there is one less magical part in the chain.

    We also fixed one recursion stack overflow bug in Cecil today, which allows us to further dig into yet another Weaver bug.
     
  38. YusukeTakehara

    YusukeTakehara

    Joined:
    Mar 13, 2018
    Posts:
    2
    Hi!
    I started using this as an alternative to UNET

    I want to use multiple clients for different purposes.
    Can not use multiple clients connected to different servers?
     
  39. YuriPetskus

    YuriPetskus

    Joined:
    Jun 22, 2018
    Posts:
    18
    After the client disconnects from the server and reconnects, the client receives exceptions such as:
     
  40. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    What do you mean exactly?

    Please open an issue on our github and let us know exactly how to reproduce it :)
     
  41. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    What's the flow to send login credentials from client to server, then check it on the server, then send OK to login to the client? All before spawning all the network objects.

    Explaining that on the docs would be interesting I think.

    Thanks
     
  42. YusukeTakehara

    YusukeTakehara

    Joined:
    Mar 13, 2018
    Posts:
    2

    Thank you for your reply!
    I want to use multiple clients for different purposes at the same time.
    So,It is not good to reconnect after disconnecting one of the connections.

    My implementation is as follows by UNET.

    Code (CSharp):
    1. public NetworkClient myClient1 = new NetworkClient();
    2. public NetworkClient myClient2 = new NetworkClient();
    3. myClient1.Connect(connectServerIP1, connectServerport1);
    4. myClient2.Connect(connectServerIP2, connectServerport2);
     
  43. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    We did!
     
    Vancete likes this.
  44. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    368
    NetworkClient is a singleton in Mirror. There can be only one.

    That said, perhaps there's a better way to accomplish what you need.
     
  45. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    No, that will just delay the player object being spawned until authenticated. He wants to do authentication before any objects, state and other information is distributed. Essentially isolated.
     
  46. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    That's coool!
     
  47. ry00n

    ry00n

    Joined:
    Mar 3, 2018
    Posts:
    6
    Just wanted to say THANK YOU for all the development effort behind Mirror! I'm just getting up to speed with game development and made a multiplayer local co-op prototype that I wanted to transition to drop-in online/local hybrid. I have to say I felt like I was in a tough spot between the upcoming (and largely undocumented) new networking API and UNET being deprecated.

    I liked what I saw of UNET but didn't want to learn an abandoned platform... so decided to get up to speed on Mirror and I'm really liking it so far! I was a bit saddened (initially) to see the drop of playerControllerID for having multiple controllers per client as I'm intending on drop-in local + online coop. I might suggest you remove the reference to that in the docs here since that tripped me up for a while: https://vis2k.github.io/Mirror/Concepts/GameObjects/SpawnPlayerCustom until I found your posts mentioning removing it.

    The solution I've developed so far is to use spawn an empty as the playerPrefab (representing the client) that has a script on it that can spawn however many local player models as game objects with client authority. It seems to be working great so far. I may put together a tutorial of the process once I get the kinks ironed out if anyone else ends up in the same situation.

    I'm also very interested in your List Server product once I get this project farther along and will likely give it a try. If you ever plan on adding punchthrough (or even some general guidelines on how to achieve that) that would make it even more valuable.

    Anyway thanks again!
     
    mischa2k likes this.
  48. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Great to hear, thank you!
    We really love the UNET architecture, and we try very hard to get it perfect.

    You can try the list server yourself, Mirror comes with an Examples/List Server scene that connects to it. The server hasn't crashed since day one, and you can even host it for free on a google cloud f1-micro instance.
     
    Last edited: Apr 16, 2019
  49. Vares

    Vares

    Joined:
    Aug 20, 2017
    Posts:
    3
    Hey, thanks for your work. Is there a way to temporarily disable weaver while i am working in the editor/debugging. Weaver makes my visual studio project undebuggable as the breakpoint locations cant be found (I assume because breakpoint locations dont match the Assembly after weaving). I don't understand exactly where it is invoked from and the only solution I have found is to delete the weaver folder entirely...
     
  50. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Try the latest mirror version from github. We fixed that breakpoint issue a few days ago.