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

Showcase Mirror - Open Source Networking for Unity

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

  1. danicolaj2

    danicolaj2

    Joined:
    Sep 10, 2019
    Posts:
    1
    Hi, I can connect clientB to HostA with Mirror, but only in LAN.

    Usually if that happens the issue is that the port is not open/forwarded properly on the modem, but I believe that's not the case: from a unix server somewhere out there in Europe, I "telnet <mywanip> 7777" and telnet connects, ONLY if my HostA is running and listening to 7777, otherwise the connection fails. I believe that proves that I can access hostA through port 7777 from the net, so port is open and properly forwarded.

    Since I'm not a networking expert.... that's pretty much where I grind to a halt.

    To summarize:

    hostA listening on port 7777 - clientB connecting to 192.168.1.33 port 7777 (LAN) - WORKS
    hostA listening on port 7777 - clientB connecting to 312.122.122.111 port 7777 (WAN) - DOES NOT CONNECT
    hostA listening on port 7777 - remote server running "telnet 312.122.122.111 7777" CONNECTS (obviously nothing happens but it connects)
    hostA NOT listening on port 7777 - remote server running "telnet 312.122.122.111 7777" does NOT connect (proving that in the case above hostA:port are reachable from the net)

    help?
    dani
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    We usually recommend hosting on Namecheap.com (not because they are the best, but it works without configuration), or Google Cloud (you do need to open firewall ports there though).

    Different hosters might require different configurations.
     
  3. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    Showcase: Project Cybertronic

    Previously developed with UNET, now powered by Mirror!
    Check out their website: https://cybertronic.red/
     
  4. Roamer79

    Roamer79

    Joined:
    Oct 25, 2016
    Posts:
    45
    Ok upgraded from 1095 to latest. Got some problems:

    ClientScene.AddPlayer(conn, msg);
    Cannot convert from Mirror.StringMessage to byte[]


    Whats changed? Having trouble finding the documentation on this update.

    Thanks
     
  5. calvinstreeting

    calvinstreeting

    Joined:
    Jun 14, 2019
    Posts:
    15
    hi.
    can mirror be used to remotly control a main camera
    aka Main Host is full screen window that shows a scene and it lanches (via button or key press) another window (threaded application call) that renders a lesser version of same scene (less graphic quality) that when the camera (orbit control) is moved this changes the camera in the main full screen parent window to match. like a remote control view sub window thingy :)

    just want to know if this is posible (before i start alot of reading and codeing the parts etc.)

    Many thanks
     
  6. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    Please post the exact error
     
  7. Roamer79

    Roamer79

    Joined:
    Oct 25, 2016
    Posts:
    45
    That was the exact error! Don't worry its fixed. Can I suggest though. Stuff like these little network manager changes break existing projects. I hope that changing the AddPlayer from stringmessages to bytes is REALLY REALLY worth it. The great thing about Mirror is that you import it and are not greeted by a sea of red. Important to keep it that way as much as possible IMHO;)
     
  8. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    We try to keep it this way, unless where completely necessary. E.g. in that case above.
     
  9. silverair

    silverair

    Joined:
    Jun 20, 2015
    Posts:
    5
    I'm thinking about a mobile game
    based on a room for 4 player.

    Making them P2P doesn't seem like a good choice.


    So I think I need to manage the server by myself.

    When the player to create room, the master server to run a server process.
    so it's dynamic create server process in each room.

    It's basically the function of Master Server Framework, the Asset.

    But this Asset doesn't seem to support mirror.


    Is there any alternative?
     
  10. Thibault-Potier

    Thibault-Potier

    Joined:
    Apr 10, 2015
    Posts:
    206
    Hi ! I'm a total noob in networking. I'm looking for basics tutorial on how to use Mirror on a unity project. I want to create some LAN multiplayer project (with no internet). Can you point me some good tutorial ? That would be super appreciated
     
  11. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    There's not a lot of Mirror tutorials because Mirror is basically Unet and there are lots of Unet tutorials made over the years.
     
    Thibault-Potier and mischa2k like this.
  12. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    officialy what's the unity solution HLAPI already drepreced too like unet ?
    thn'aks
     
  13. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    See all the sticky threads in this forum. The official Unity solution is currently under development, though there is alpha code released for you to preview, as well as alpha quality documentation.
     
  14. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i want say lol
     
  15. FuhaoXie

    FuhaoXie

    Joined:
    Nov 18, 2016
    Posts:
    26
    Seems Mirror dont have lan matchmaking, I think it will be very useful to provide a lan matchmaking feature for developer.
     
  16. sth4881

    sth4881

    Joined:
    Oct 1, 2019
    Posts:
    3
    Hi there! I'm interested in Mirror which could replace the UNet! I tried to install it but found a big problem. When adding component like NetworkManager, NetworkIdentity, it was fine but when I tried to make a script importing Mirror and using NetworkBehaviour, 2 kinds of error happens. How should I fix this bug? upload_2019-10-10_17-32-59.png
     
  17. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    Someone sent us a pull request already: https://github.com/vis2k/Mirror/pull/1024
    We are still considering it. Feel free to try and let us know if it works for you.
     
  18. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    Looks like you didn't import it properly. Go to the Unity Asset Store, search for 'Mirror', get it from there, try to extend our examples.
     
  19. FuhaoXie

    FuhaoXie

    Joined:
    Nov 18, 2016
    Posts:
    26
    Another issue is ,when I attach unity using vs first, and then start editor. the editor will freeze even I dont set any breakpoint on it. This editor freeze always happen when attaching the editor
    My unity is 2018.4.4f1 and vs 2017.
     
  20. tranos

    tranos

    Joined:
    Feb 19, 2014
    Posts:
    180
    Hello to all! I want to make registration and login for Lan. Username and password will be stored in the local server. How can I use Mirror to do that? Thank you.
     
    Last edited: Oct 10, 2019
  21. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    I'm starting a new project and this will be my first game with multiplayer. I've recently been wading through all the multiplayer options and Mirror looks like the path I need to take.

    My game will feature lobbies of 10-20 players and projected playerbase in the 3-5k range monthly. But who knows it could take off even bigger.

    For my scalable cloud servers, I've checked out Amazon AWS and it seems pricey for an indie. Is there a better alternative? I found 2 others that seem to offer a similar service, the first being Hostwinds.com and the other Vultr.com.

    Anyone's thoughts and recommendations would be appreciated.
     
  22. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    With the cloud services you're paying a premium for convenience and redundancy. Spending a while looking for the best deal in price to the resources you get, it is pretty clear the best deal is if you rent somewhat outdated dedicated servers. For example, for my game I pay $65/mo for 16 cores of Opteron 4284, 32 GB RAM, 2TB HDD storage, and 25TB data transfer. If you used a similar amount of resources from AWS the cost would be considerably higher ($1k maybe?). Check out Joe's Datacenter (no affiliation with myself other than being a customer, regardless of my username).

    The big negatives are you are unlikely to fully utilize all the available resources of a dedicated server every month, and a dedicated server is more prone to going down for a hardware failure than a cloud virtual server, since cloud servers can be moved between physical hardware as needed seamlessly. But depending on your game, renting multiple dedicated servers may actually save you a considerable amount of money than going the cloud route. YMMV
     
    Willbkool_FPCS, digiross and TwoTen like this.
  23. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    @Joe-Censored you confirmed part of what I was thinking by going the mirror route. The dedicated server you have, how many players could you reasonably expect to support. For instance, say you have a 16 player game, how many instances would it support so I could guesstimate how many servers I would need depending on game sales/popularity. That seems to be part of the factor as to why people are going balance loaded cloud servers these days. Not to mention the dependability/redundancy you already mentioned.

    Adding multiplayer definitely magnifies the issues compared to singleplayer. :eek:
     
  24. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    That's a very difficult question to answer, as it depends entirely on your game. A card game or simple turn based game for example, you might be able to support thousands of users. A very high speed game requiring lots of CPU or memory resources though might bottleneck you there with relatively small numbers of users before network usage even matters though. Run your server instance on your home machine in headless mode and look at its resource usage to get an approximation for how many of it you can run on your server.

    You could also consider using dedicated servers for your expected capacity needs, and spinning up cloud servers as needed when demand exceeds capacity.
     
    Last edited: Oct 12, 2019
  25. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    Thanks for the insight! :)
     
  26. FuhaoXie

    FuhaoXie

    Joined:
    Nov 18, 2016
    Posts:
    26
    Is there a quick Relieable UDP solution in mirror?
     
  27. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    363
    There are a bunch of different transports for Mirror, including two that are UDP-based.
     
  28. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    363
  29. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    The mirror profiler is now available to all our patreons

    You can easily find out what objects are sending what messages and tune your bandwidth utilization.
    Read the documentation for instructions as well as suggestions for improving your game.

    Some key features:
    • Simple and intuitive, just open it and press record
    • Inbound and outbound messages, even your own messages
    • Sort the messages by any field
    • Shows chart by message count or by total bytes
    • Zero overhead if you are not using the profiler
    • It can save and load profile data
    • Show all frames or only frames with messages
    • Displays name of your commands and rpcs
    • Displays the object that sent the command, rpc, syncvar or being spawned
     
    Slaghton, FuhaoXie, hopeful and 2 others like this.
  30. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Is here any Playmaker actions available for this asset?
     
    Lars-Steenhoff likes this.
  31. IkeRoyle

    IkeRoyle

    Joined:
    Sep 11, 2018
    Posts:
    2
    Hi, sorry for the highjack but it seems you and I are starting very simmelar projects. I'm building a physics instance based game with simmelar requirements. I was insprired by this blog using Kubernetes! Maybe its some use for you like it was for me! :)
    https://www.compoundtheory.com/scal...bernetes-part-1-containerising-and-deploying/
     
  32. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    @IkeRoyle thanks for the link, i'll have to check it out!
     
  33. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    363
    Not from us, but Mirror works with Bolt Visual Scripting according to one of our users.
     
  34. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    There seems to be a bug in the Room example. The problem is that NetworkManager.clientLoadedScene is never getting set to true, and NetworkManager.clientReadyConnection is always null. This is happening because in NetworkManager:OnClientAuthenticated (line 929) you are testing IsNullOrEmpty(onlineScene) and the Room example requires onlineScene to be empty.

    You can repro this by running the Room example and once you have started the gameplay scene you will see that clientLoadedScene is false and clientReadyConnection is null. The expected behavior is that these values will be set correctly.

    Thanks
     
  35. sth4881

    sth4881

    Joined:
    Oct 1, 2019
    Posts:
    3
    I downloaded ur asset 'Mirror' and extracted to the Asset folder. Should I have to do anything more?? I didn't understand about how to 'try to extend our examples'. TY so much for replyi
     
  36. sth4881

    sth4881

    Joined:
    Oct 1, 2019
    Posts:
    3
    Finally, I made it by extracting the latest version of mirror in 'Asset' folder. Now I can use it. TY
     
    mischa2k likes this.
  37. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    We'll look into it!
     
  38. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    Progress Update: we reimplemented authority from scratch.
    A player now has authority over a GameObject if he can call Cmds on it. That's it, nothing more.
    We also removed local player authority, which meant 'trust the client with everything', as opposed to the default 'server authoritative' design where the server makes all the decisions.
     
  39. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    There is one case where local player authority is necessary.

    In FPS game, when you shoot an enemy, you need an immediate response. The client detects the hit and tells the server that it hit the enemy. Without this, there is no way that hit detection can be made accurately in a responsive way.

    Not sure why you removed the local authority but it should be a choice from the developers.
     
    Hertzole likes this.
  40. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,341
    You can still do this. For example, you could use a command like [Cmd] CmdFire(Ray ray) to let the server know where the player fired.

    The whole local authority feature was very strange. It meant that the client would be trusted with everything.
     
  41. kirbyderby2000

    kirbyderby2000

    Joined:
    Apr 28, 2017
    Posts:
    35
    I have really dumb questions. So I'm currently reading through the Mirror documentation and tutorials, which is all fantastic by the way, great job! Now I only have a couple questions:

    1. Do I need a dedicated server with Mirror in order for clients to connect to each other / matchmaking?
    2. If I do need a dedicated server, is there a guide or tutorial on how / where I can deploy the server onto something like Azure or AWS? I can't seem to find any resources on this topic if it's required.
    3.I also can't seem to find any resources on writing match making logic on the server's side. Does anyone have any tips on figuring out how to do that?

    Sorry, I'm pretty illiterate when it comes to networking but I'm slowly coming around.
     
  42. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Thanks. I thought so.
    I suppose local player movement control is also can be achieved similarly. Local player detects the collision locally and sends the position to the server and the server just check if there is a hack or not.
     
  43. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    I have one more question about the local player authority.
    Assuming you have authority over your own character, meaning you control, detect collisions and sent the final transform information to the server, does this require local player authority?
    If not, what authority do you have when you are controlling your own characters?

    A similar situation can happen when you drive a car.
    Car, when undriven, it will be controlled by the server, such as rolling down the hill when pushed by some force.
    However, when a player takes control of the car, everything will be simulated and controlled by the client and final transformation will be sent over the server.

    Transferring this control from server to client, does it involve the local client authority?
    I'm a bit confused about what local player authority means and what we need to do to workaround in the absence.

    Thanks.
     
  44. eaquino_unity

    eaquino_unity

    Joined:
    Aug 13, 2019
    Posts:
    13
    Hi,

    I have a question regarding Mirror, in Photon there is a function using AllBuffered that allows a disconnected client after reconnecting with the host, retrieving all the information from the server and clients (Objects in scene, transformed, size, variables, etc. ).

    With Mirror can I have that functionality? because at UNET I can't find a way to implement it.

    Thanks!
     
  45. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    363
    Mirror automatically delivers the current states and objects whenever a client connects, whether they were connected before or not.
     
    mischa2k likes this.
  46. MrG

    MrG

    Joined:
    Oct 6, 2012
    Posts:
    363
    Mirror has AssignClientAuthority and RemoveClientAuthority for that.
     
  47. Enignum

    Enignum

    Joined:
    Feb 28, 2017
    Posts:
    8
    Hi,
    I'm thinking of example: 50 players in a game, 50 rigidbodies...
    Do I have to try some sort of optimizing or just slap NetworkTransform to the Rigidbodies and it should be fine? Or will it be too much for the server/connection/lag?

    What about "Smooth Sync" from the Asset Store? Does it have sense or is Mirror already optimized enough in this case?

    Thanks! ;)
     
  48. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    How often you need to sync things, and how much data you need to sync, will dramatically affect how well that kind of set up works for you. For example, just with transform updates if you need to update all 50 rigidbodies to all 50 clients at 29 times per second that will be a significant number of messages compared to updating at a lower rate (say 5 times per second) only to nearby clients. You'll undoubtedly have other data as well you will want to update on a regular basis.
     
  49. Enignum

    Enignum

    Joined:
    Feb 28, 2017
    Posts:
    8
    Let's say it's some sort of Golf game and rigidbodies can collide with each other... So frequent updates for smooth gameplay and most of the time most players will see them :(
     
  50. Johan_Valectric

    Johan_Valectric

    Joined:
    Nov 28, 2019
    Posts:
    13
    I'm looking for a freelancer who has done some work using Mirror? I'm searching on Fiverr but it takes time to find a good one so any tips is most appreciated. You can shoot me a PM or an Email at johan.holtby@valectric.se so we don't hog this thread. Also tips on where to post other than here is appreciated. :)