Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Making a multiplayer game? Read this.

WarpWarp Member
edited May 26 in Programming

So something I am noticing across the programming forum is that the "How do I do multiplayer" question is raised multiple times throughout the day, almost every day. The purpose of this post is to clear up some confusion about multiplayer, and how to implement it.

WHAT YOU SHOULD KNOW:

There is no universal way to implement multiplayer into Unity as of now. Many people reference the Brackeys "How to make a multiplayer FPS" tutorial as a guideline, but this should not be used as a way to implement multiplayer. In that video, Brackeys uses "UNET". This is Unity's old, legacy networking system that is being phased out.

If you make a game with UNET, that code will be obsolete and unsupported in less than a year. You can read more about UNET deprecation here.

Before I go into depth, I want to point out that networking is not only difficult, but it requires knowledge in C# and networking itself. Please make sure you understand how Unity works, and at the very least can program small games on your own, with minimal help from tutorials. If you dont know what you're doing, networking a game will hit you like a pile of bricks.

READ THIS ARTICLE! It has information about different networking protocols, and networking theory that will be imperative to your success!

OPTIONS:

Until Unity's new networking system is released, and complete, you're going to have to use your own networking code, or 3rd party software. Lets talk about the pros and cons of these.

PHOTON

  1. Photon is a tried, tested and solid option for networking. Its free on the asset store, relatively easy to set up, and has a ton of examples to get you going.
  2. Has a forum and developer support
  3. Uses a client-client model with a cloud server.

FORGE NETWORKING REMASTERED

  1. My personal choice, and what I recommend.
  2. Has built in NAT punch through software to allow for client server -> client models, used in games like Call of Duty.
  3. Free and open source
  4. Tons of examples, and a powerful, easy network wizard to set up everything.
  5. Works outside of Unity. You can use Forge to network anything.

YOUR OWN IMPLEMENTATION / C# SOCKETS

  1. You control what happens. You dont wait for updates, and you own the software.
  2. You understand whats going on, and can tailor it to your game.
  3. Much more advanced. Requires knowledge of sockets in C# and networking systems.
  4. Hard to make, and prone to error unless done well.

USEFUL NETWORKING INFORMATION:

Transmission Control Protocol - Wikipedia

Socket Programming In C#

Network Programming in the .NET Framework | Microsoft Docs

https://mirror-networking.com/

There are many more systems you can try and use, these are just popular ones you might want to try. If I made any mistakes please correct me, I am not an expert. I just see this question very often.

Comments

  • WarpWarp Member
    edited May 23

    If you have any corrections, questions, or info about other software to put onto this list @Warp me, with a list of pros, cons tutorials etc and I will amend this post to reflect that.

  • thanks

  • Roby65Roby65 Member
    edited May 24

    I never used it, but Mirror is popular too: https://mirror-networking.com/

    I personally went with the websocket approach when I needed multiplayer but I plan moving to one of those soon

  • WarpWarp Member

    @Roby65 I actually wanted to add Mirror to the list, but there is a letter limit. Im going to make a comment with some extra software people can use. Thanks!

  • JosephDZJosephDZ Member

    that helps me a lot , but i believe that every big thing come by steps , as an amateur in game dev world i think we should make it step by step , muliplayer is an advanced level .

  • Forge also has a very helphulf community... You should join their discord even the creators of forge try to help you with any questions.

  • FissionerFissioner Member

    I have used both forge and mirror and I can say that both have absolutely great communities with devs ready to help anytime. I just find mirror easier to use, so I went with it, but your preference may vary.

  • MuradoMurado Member
    edited May 24

    Nice Post, this should be pinned!

  • Sl0thSl0th Member
    edited May 25

    I have recently had to make the decision of which path to take, and this post is very helpful to answer some of the questons I had. There is, however, still something I am unsure about - which is what Unity advices people to do. I haven't paid much attention to Unity's development the last few years, but from my understanding, this has been going on for a couple of years. And it will go on for one or two more, right? When you visit the UNET manual, you are told that it is deprecated and that you can see a blog post or FAQ to get more information. They have a flow chart that shows which system you should use, but it seems... Odd. And not very actionable. UNET will be deprecated, so it seems silly to pick that up now. But the new system is not at all done, and I have found next to no information about it (except for people explaining what it is). Unity's official web page on it seems more like an abstract ad with fancy buzz words than something that might be helpful.

    Does Unity have any actionable advice on which path to take? Or is it simply left up to the community to figure out some Thord party software in this 4-year void? Have I missed something obvious?

    Cheers

  • FissionerFissioner Member

    I do not know about "Unity's actionable advice", if they had one, we probably would have known it. But, the reason why mirror and forge exist is the void you mentioned. Mirror for example is better version of UNET, simply put.

  • WarpWarp Member
    edited May 25

    @Sl0th

    That is exactly what prompted me to make this post, other than the people asking about it on the forum. Unitys manual has an entire section dedicated to UNET multiplayer, but at the top of every single page in the manual is a link to the deprecation page.

    I dont understand why Unity is treating multiplayer this way. Its a real shame too, because the new system will apparently not have good P2P support, which is what made UNET so great. The P2P relay system was awesome, because you didnt need to pay for servers. Now, it looks like they're leaving indie multiplayer in the dust.

    They don't have any official advice as far as i'm concerned, but I dont care. Forge is better than UNET. Photon is better than UNET. Mirror is better than UNET.

    I probably wont even check out their new multiplayer system. I dont trust them enough for it. Forge suits my needs, is open source, and has P2P capability, which is literally #1 when it comes to indie multiplayer.

    Ill be sticking with 3rd party software for multiplayer.

  • Sl0thSl0th Member

    @Fissioner @Warp

    I see. Thanks for the replies!

  • WarpWarp Member

    Happy to help!

Sign In or Register to comment.