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 Administrator
edited January 22 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 talk about options, 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 some information about different networking protocols, and networking theory

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.

UPDATE 2023: Netcode For GameObjects/Entities has been released. It is quite nice even though it has some issues. Code monkey and the official unity documentation are great resources if you wish to use this system.

https://docs-multiplayer.unity3d.com/netcode/

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. Battle tested
  3. Has a forum and lots of support

FORGE NETWORKING REMASTERED

  1. My personal choice, and what I recommend.
  2. Free and open source
  3. Tons of examples
  4. 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


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 Administrator
    edited May 2020

    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 2020

    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 Administrator

    @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!

  • 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.

  • 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 2020

    Nice Post, this should be pinned!

  • Sl0thSl0th Member
    edited May 2020

    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

  • 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 Administrator
    edited May 2020

    @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 Administrator

    Happy to help!

  • @Warp This is a perfect discussion, thank you.

    June 2020 - I am trying to get ECS + NetCode working on 2+ physical devices and am struggling. I have tried all the samples at https://github.com/Unity-Technologies/multiplayer with no luck as well as the DOTS Sample, which works brilliantly with Thin Client bots, but even if I build a Server and Client build and have running on the same LAN, they just don't connect.

    I DID get the FPS Sample working perfectly with very little effort, so I could theoretically strip that down and start from there, but that seems a very hard way to get going. I'm happy to advise on how I did this if anyone wants to know.

    I also recently stumbled on DOTSNET, but haven't checked that out yet.

    Does anyone have a good way to get an absolutely basic ECS/Netcode mutliplayer actually working on 2+ physical devices on a LAN?

    Thanks all!

  • Thank you very much for this! It'll be super useful in the future, I'm sure! <3

  • I have been looking for networking solution for some time, trying the Forge Networking Remastered now.. thanks!

  • does anybody knows a tutorial series about full photon setup in unity.i really want it.

  • Search on youtube

  • gamedev64gamedev64 Member
    edited May 2021
Sign In or Register to comment.