I tend to first tackle the most difficult / least-known areas in a game project, so that I can then work on other easier-to-handle areas with less worries. I have no prior experience in implementing internet connection for online multiplayer games (the closest I've done was split-screen local multiplayer), so this is the topic that I looked into afterwards.
Watching different YouTube tutorials, I learned that there are different multiplayer connection infrastructures — LAN, Peer-To-Peer (Direct) / Peer-To-Peer (Player Hosting) / Dedicated Server, and different protocols — Transmission Control Protocol (TCP) / User Datagram Protocol (UDP), and they use Remote Procedure Call (RPC) in the communication between devices. Those were all new terms and concepts to me so the learning curve was a bit steep.
Moreover, it was totally overwhelming about how many types of networking frameworks are available (Unity Gaming Services, Epic Online Services, Microsoft Azure PlayFab, Amazon GameLift, Google Cloud Platform, Photon PUN 2 / Bolt / Fusion, MLAPI, UNet, TNet, ENet, Mirror, Fish-Net, DarkRift 2, RakNet, Normcore, Forge, Steamworks, SmartFox Server 2x, Gamesparks, Firebase, Blazor, the list goes on...). I spent a considerable amount of time (about 2 weeks) on learning about them and comparing the pros and cons of each one. Maybe I shouldn't take that long and should just have picked one to start trying to use, but at that time I wanted to avoid investing in learning to use something that it is not very good or I don't really like, so I wanted to decide carefully.
I settled with Fish-Networking (Fish-Net), followed the official Fish-Networking tutorial on YouTube to learn using it and made a build that can connect with other instances within localhost (Fish-Net Tutorial (Localhost)).
Video link: YouTube / Google Drive
At that time, I was thinking to use a dedicated server for server-client connection, and I decided to try Microsoft Azure PlayFab for getting a dedicated server. I was looking into if I could make my Fish-Net build above connect to the PlayFab server. However, this is too technical and it requires higher programming capability to understand the codes that are used to communicate with PlayFab server. It got a bit out of hand so I decided to consult Dick Thung my FYP advisor about it.
Following my advisor's advice to use first-party framework if possible, I switched to use Unity's Netcode for GameObjects along with the use of Unity Gaming Services (UGS). I also found Tarodev Unity Matchmaking (YouTube tutorial), a good template to start with creating a multiplayer lobby. Following some additional tutorials about how to use Netcode, I merged this project with my main project together and created a simple lobby connection that can let players see each other's car.
Video link: YouTube / Google Drive
The lobby hosting shown in the video was using the relay server from Unity Gaming Services. There was still some player collision issue to be improved, and in the editor console it actually kept saying an error of NullPointerException (the RVP car needs to instantiate an empty gameobject for its own use, but I haven't looked into how to spawn objects for connected clients) which I couldn't fix yet.
This is the point in multiplayer connection I got to so far. After that I considered the tight schedule, and decided that I need to make progress on the map and gameplay programming first, then come back to this multiplayer part with a more established base game.
Did you like this post? Tell us