Mirror Networking for UCC Add-on

Matt

Member
To help keep the PUN Network announcement thread clear of Mirror discussion, this is the thread for the UCC Mirror Add-On.

Please note that this add-on is currently under development and is not available for purchase. More details including the pricing and any closed alpha/beta testing will come in the near future. This is mainly a discussion thread - any progress will be posted as milestones.

The idea of my Add-on is to make it as transparent as possible so you don't have to get your hands dirty having to write the network code yourself. Basically, the features you see in the PUN integration should be in my Mirror add-on.

Let's get started!

Is Mirror better than PUN?
Please note that my PUN knowledge might be very limited and/or incorrect. Do your own research about PUN before taking my words seriously! ;)

Both Mirror and PUN do the same thing - network your game. However, it's how the implementation is done.

Photon Networking
PUN is based around P2P, where one client in a room is a host client while everyone else are clients. The host client and standard client(s) chat to each other and say for example "Hey I shot Sarah for 5 health", "Hey Justin just killed me with a RPG, respawn me please", "Moving to position XYZ", "I'm aiming at the sky" back and forth, much like console P2P games (see Modern Warfare and Modern Warfare 2 on PS3/Xbox 360). These messages bounce back and forth between all clients all at the same time.

PUN is also based on a subscription model, being that you pay for the CCU and Messages Per Second. Your game gets relayed through Photon's Cloud services so players can be on a really bad connection and Photon still has your back.

Photon is designed to get you running FAST. It's also ideal for games that need quick and dirty network prototypes up and running without the fuss of server instances etc. However, for some games like shooters, unless you are willing to spend big dollars on anti-cheat solutions, it makes sense to forfeit PUN for a server authoritative solution.

Techy details:

PUN uses a CCU system which 1 connected client is 1 CCU. CCU stands for ConCurrent Users. Each subscription tier has a CCU limit and Messages limit.

The benefit of this model is that it's easier as you have a fixed cost every month to run your game online, and it's faster to deploy. Exit Games also have cloud relays implemented so that you and your mates can connect anywhere when you have a stable internet connection.

The downside to PUN is that it seems that the Game Server host has to be Windows-only (citation needed) and some people don't like this subscription based system. PUN provides Networking as a Service (NaaS) and Exit Games could boot you off their services at any time.

There's also the problem of room security - unless you're using encryption, there's been hackers that breach the protocol layer of the Photon networking layer and can take control of rooms. For example, we had a developer come from PUN to Mirror because he had to bribe a hacker to stop ruining his online experience since the hacker would connect, take control of the room and randomly spam "kill player" packets to everyone for easy wins. This could be avoided by using encryption, for example.

Mirror Networking
Mirror started out as HLAPI Community Edition. As someone who used it in the past for TPC 1.3.x networking, it was a godsend over Unity's buggy UNET implementation. Mind you, we are not talking about the new UNET that Unity is taking forever to implement with their "Multiplay" services - we're talking about the old UNET that has been around since Unity 5. The Mirror team focuses on stability and bug fixes over new features.

That said, the Mirror Networking API is completely open source apart from some paid add-ons that enhance things like 1000+ CCU. The benefit of being open source is that you can easily look at the code when you encounter a bug and get an idea of the code path your code is going through.

Mirror is designed for server authoritative networking in mind. Basically, the server instance - be it a Dedicated Server or Host Client instance - barks the orders and the clients must acknowledge them or they'll be booted off the server. Clients use Commands and the Server uses custom Messages or RPCs (Remote Procedure Calls) to tell Clients what to do. If a client tries to do something that requires server authority like set someone else's health on an object they do not own, then they are denied and an error is thrown.

This makes it possible to use your own infrastructure in the form of cheap VPS from providers like Linode, Vultr, etc to run your online game servers, be it Windows, Mac or Linux. Or if you have the cash, you can rent a dedicated server with a full remote access solution and have real performance like how AAAs run the show. I have a in-house test server in Sydney that has this setup and it's sweet.

The downside is you need to know how to maintain a Windows/Linux based server and also open ports on the firewall. Linux based VPSes are cheaper and more secure to run, but you have to learn the Linux way of running binaries while Windows is point and click. Once that's sorted you're smooth sailing.

What will I need to use this Add-on?
First and foremost, you must lock yourself onto a version of Unity. For example, the Mirror team recommends Unity 2018.3 or 2018.4. That means that you do not upgrade that version of Unity unless a patch for a specific bug that you're facing has been released. Mirror does work with Unity 2019.1 but it can have some quirks. Pick your poison.

I see a worrying trend of new developers updating to every minor dot point in a Unity release and this is a bad idea. If you are going to be serious about your network game, you make sure you choose a version that will work and keep using that version until you face a bug that forces you to upgrade. You do not want to upgrade every dot release and then find a bug in that release has just completely killed your project beyond recovery.

Do not simply just upgrade because "oooh, shiny new features" - majority of the time you do not need the upgrade unless you are experiencing a bug that has been fixed. Professional developers don't upgrade versions on a dime. With that out the way, here's the dependency list:

  • Mirror Networking. It is safe to import Mirror now from the UAS, it will not break any UCC code and you'll get a kickstart. I will not be bundling Mirror with the add-on, you will have to install it as a dependency.
  • Ultimate Character Controller, version 2.1.5 onwards
What about client prediction and server replay?
This topic is very advanced and will eventually be included in a later milestone demo and/or post-addon launch. Right now, the goal is to use the basic Mirror API to get the controller networked and moving around, then going up the chain.

Does this include features like Team Deathmatch, Battle Royale, etc etc?
No, you will simply be getting a base network implementation that you can extend from there, much like the PUN implementation. You will not be getting a full networked game template, where you can just throw some characters into a scene, click a button and a fully functional networked team deathmatch implementation is yours.

The demo scene will most likely include a free for all barebones mode that allows you to get a feel for the add-on.

Can I use this as well as the Photon Networking add-on at the same time?
Not recommended at all - don't even think about it. Trying to mix and match network systems never goes well and you will get breakage. You either choose PUN or Mirror based on your needs.

Alright, this post will be updated as time goes on. Ask any questions you might have. Cheers!
 
Last edited:

chrisk

Active member
Sounds super awesome! I'm really looking forward to this one.
I have a couple of questions now.

1. How soon do you think we can have something to test, after PUN2 releases?

2. Will it support join-game-in-progress?

3. Will it come with some example such as Lobby and a sample game mode, e.g., basic TDM, or Free-For-All? I know you mentioned it will not come with full TDM but some example from the lobby to a game will help.

Thanks.
 

Matt

Member
Sounds super awesome! I'm really looking forward to this one.
I have a couple of questions now.

1. How soon do you think we can have something to test, after PUN2 releases?
Probably a few weeks. I am currently doing contract work for other developers so it depends on how that goes and what time slots my real life IT consultation clients consume.

I have a private Notion task board that has 3 milestones. We're going to piecemeal the development of this add-on (read: taking it in baby steps) so it isn't overwhelmingly difficult to implement, but I will be updating here as soon as we have progress. As milestones come along, I will most likely be releasing playable Mirror network demos.

2. Will it support join-game-in-progress?
Mirror by design will bootstrap any client that joins in the middle of a match, but it's up to you to implement such functionality if players should only spawn when a game is not currently in-play. But the answer to this question is yes, you should be able to join in the middle of a round and start fragging away.

3. Will it come with some example such as Lobby and a sample game mode, e.g., basic TDM, or Free-For-All? I know you mentioned it will not come with full TDM but some example from the lobby to a game will help.
I'll most likely have some sort of Demo mode, probably free for all with a crude scoreboard tracking all thrills and spills. I don't want to include too much gameplay in my add-on as it's supposed to be a basis for your own networked gameplay implementation... although I'm half expecting someone to asset flip.
 

chrisk

Active member
Thank you very much. I'm happy to hear the answers. It really makes me exciting. I'll try to do my best to test once it's available.
Cheers!
 

Matt

Member
I should clarify that I will most likely have a Milestone demo a few weeks after the PUN add-on releases. This first demo will most likely be a proof of concept and just have the core mechanics (ie the interaction room like in the PUN add-on). I won't be doing closed alpha/beta of the add-on until later in it's development.
 

Matt

Member
Hi will we need the full UCC product or will it work with UFPS2?
I'm developing it with UCC in mind, when I get to release stage I will probably try to get it working with UFPS2 and friends. Since it's all the same code base, it should work - probably need to make some definitions to toggle things in the code.
 
Top