A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Introducing the new Universal Render Pipeline and High Definition Render Pipeline subforums!
Unity 2019.3 Beta is out now.
Discussion in 'Connected Games' started by vis2k, Aug 11, 2016.
Yes, that's doable. Mirror is server authoritative by default.
I'll be working on it and testing intensely throughout the week. It's likely to have problems in its current state, but it's a start.
Questions for the more learned:
I wanted a way to be able to unregister events for cleaner shutdown, so in the root MirrorpunchSteam I set Action variables to lambda expressions so I could do so. Are there any issues with this approach?
How does the NetworkManager handle connection ids, if I'm assigning them in the transport. Is it fairly agnostic to how it routes data associated with connection ids?
thanks for the reply. Does mirror also support matchmaking and room creation?
there is a way co connect with another project to a main project network? I wold like to create two different unity projects that use a thirf project as server for sharing data.
could this be possible with mirror?
Could you please point me into the right direction?
Latest showcase: Rogue Star Rescue - a roguelike tower defense game made with Mirror!
It's not in Mirror by default, but you can do that with Mirror.
We recommend using one project for everything. That's what Mirror was for after all.
I know that but I need to control some parameters by a different device, and is impossible to make that project work on a very different device.
So it's impossible to make connect two different projects?
If I use LLAPI to create a custom socket, do Mirror could have any trouble?
Not 100% sure what you mean. Perhaps our Multiplex transport is useful for you.
Hello - I need to send a collection of structs or classes to a client using TargetRPC. The data is just a string and an int. I am currently planning on doing this as follows:
void TargetSendData(NetworkConnection conn, List<MyThing> data)
// do stuff with data
My question - Is this the best way to do this in regards to network performance and bandwidth? Should I use a struct instead of a class? Possibly a different type of collection vs List?
This is not something that will be called repeatedly but I'd still like to keep it as performant as possible.
New Feature: SyncToOwner. Each component can be configured to sync to all observers, or only to owner. This will save large amounts of bandwidth for components like a player inventory, that shouldn't be synced to anyone else. Enjoy!
You can't send Lists in Rpcs. Only simple types like int, string, bool, int, string, etc. and structs like SomeStruct, SomeStruct, and so on. In your case, simply send an Array and make sure that it's a struct.
Hi Does Mirror supports NAT punch through? Also, does it support console platforms? Has anyone shipped a game using mirror on console platforms? Or attempted?
Check out mirror-networking.com for our showcase.
Mirror doesn't really care what platform you use it for, they all work.
Check out our UDP transports, I think a few of them might be able to support nat punchthrough.
New Feature: Custom readers and writers.
Since the dawn of time, HLAPI and Mirror have only been able to deal with a limited number of data types. Simple things like passing a DateTime or Uri as parameters in your [Command], [Rpc] or [SyncVar] would give you an error.
Starting with version 3.17.2 available at https://github.com/vis2k/Mirror/releases, you can extend Mirror and add support for any type you desire. All you need to do do is add extension methods for NetworkReader and NetworkWriters. For example:
public static class DateTimeReaderWriter
public static void WriteDateTime(this NetworkWriter writer, DateTime dateTime)
public static DateTime ReadDateTime(this NetworkReader reader)
return new DateTime(reader.ReadInt64());
There is no reflection involved. The weaver will find your extensions and use them just as if you were writing the code by hand, there is no performance penalty at all. Thanks to @vis2k for keeping me honest and help me find the simplest way to achieve this feature.
Hi, with mirror what are my options of sending RPC to specific clients?
You use a [TargetRpc] for that. The first parameter is the connection to the client you want to call. See here for docs: https://mirror-networking.com/xmldo...unications/RemoteActions.html#targetrpc-calls
Hello - I noticed in some of the comments that you have removed a lot of linq code for performance reasons. Can you talk a bit about this? I was not aware that using linq is a performance hit, and a quick google search seems to indicate that it is not. I'm just curious.
A lot of the Linq functions cause allocations which are pretty performance heavy and can cause big spikes on CPU. You can observe this in the "GC Allocs" column in the Profiler.
Is there a way to get the connected users before connecting to a server? I want to make something like a server list.
Check out our list server: https://mirror-networking.com/list-server/
Hello and thanks for the info. Another question - what about using Async and Await? Is this frowned upon for the same reasons? I seem to recall you guys ditching these functions too. Should I use Coroutines over asyncs?
Async/await is common thing to use in C#. Unity's mono backend however seems to have serious performance issues with that. None of the async/await transports that we tried managed to scale past 100 CCU. It's so slow in Unity that we end up with 120 second latencies.
If you use a few async/await calls for non-transport stuff then that's probably fine of course.
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.
hostA listening on port 7777 - clientB connecting to 192.168.1.33 port 7777 (LAN) - WORKS
hostA listening on port 7777 - clientB connecting to 322.214.171.124 port 7777 (WAN) - DOES NOT CONNECT
hostA listening on port 7777 - remote server running "telnet 3126.96.36.199 7777" CONNECTS (obviously nothing happens but it connects)
hostA NOT listening on port 7777 - remote server running "telnet 3188.8.131.52 7777" does NOT connect (proving that in the case above hostAort are reachable from the net)
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.
Showcase: Project Cybertronic
Previously developed with UNET, now powered by Mirror!
Check out their website: https://cybertronic.red/
Ok upgraded from 1095 to latest. Got some problems:
Cannot convert from Mirror.StringMessage to byte
Whats changed? Having trouble finding the documentation on this update.
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.)
Please post the exact error
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
We try to keep it this way, unless where completely necessary. E.g. in that case above.
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?