100 Years of Multiplayer Infrastructure

I just posted the code for my action system here, if you want to skip to that!

Hello! I am sure all my loyal fans have missed me. I have been busy! I am going to post a bunch of things in the next few days, in the goal of being better at publicizing the stuff I am working on, because I have made (parts of) a lot of really cool things & I am excited to share them. This is the most boring & least visual of my current projects, so it goes first.

About 5 months ago, I convinced my oldest best friend (we met when he was 3 days old & I was 3 weeks old) to work with me on making a game we have always wanted to create! I’ll post more about the gameplay dynamics when that is further along, but it is a combination of the board game Smash Up, Pokemon, & Slay the Spire. We have play tested it pretty extensively on paper & pen, which I want to make a blog post about soon, but once again, that is for later.

The obvious road block for this project was going to be the fact that I have never finished a multiplayer game before. I am really drawn to multiplayer–to me, one of the most beautiful things about games is the fact that they are the most social & collaborative form of entertainment–but both my previous projects I have left to sit around. I would get the multiplayer working, but going a step above & making it responsive, & feel good to play, was much harder.

In my now 3 attempts to start using multiplayer, I have used 3 different networking solutions:

  • Photon PUN 2
  • Unity Netcode for Game Objects (NGO)
  • PurrNet

I don’t want to give any wrong impressions, I don’t know which one of these is actually the best. However, my experience is that they are ordered above in most difficult to easiest–that is the order I tried them all as well, which could easily be impacting my decision making.

I attempted to use Unity NGO for about 4 months when I started this project, & I got pretty far! However, I became very frustrated by the lack of clear documentation very quickly. I pretty quickly ran into one problem with networking, that I realized I would have to solve before doing anything else. Here it is:

My card game infrastructure is based pretty closely on this tutorial, from The Code Otter, who I love. I had to make some major changes, given that my game is two player, but the overall structure is as follows:

  • All cards have 3 aspects:
    • Data (the template for the card, of which there is one for each card, serialized from a JSON file)
    • Model (holds the state & specific information for each instance of a card, such as modifications, health, & other vars)
    • View (the intractable element of the card)
  • All gameplay mechanics are GameActions
    • For now, I am focusing simply on Draw, PlayonBase, and EndTurn as actions.
  • All GameActions are executed through the singleton ActionSystem
    • For each action, the ActionSystem keeps track of any reactions that happen before or after a specific action. If there are reactions, those trigger as independent recursive GameActions through the ActionSystem as well

What I came to realize, after I had set up this whole architecture successfully the first time, is that the singleton structure was not communicating over the network. It took me a long time to understand exactly where the singleton structure was in the program, if there was actually just one or two because both client instances create an ActionSystem, and how to modify that code.

My current, much more fundamental understanding of Networking comes from this video tutorial, which totally rewired my understanding of multiplayer games from the ground up. As someone who watches a LOT of game development tutorials, this is real gold, I cannot recommend it enough! PurrNet is so well documented, and has a lot of features I really found useful in my implementation, especially being able to send observer & target RPCs from client instances, and the ease of use of SyncVars.

Said SyncVars in PurrNet were exactly how I solved my problem with the ActionSystem/Singletons across the network! In my new project I was able to get the end turn GameAction communicating across the network in a week from when I started using PurrNet, which might seem like a lot, but was record time compared to how long it took the first time around.

I unfortunately don’t have much to show for this project, I will attach some random screenshots below, & this is the first project where I was really dedicated about using a GDD–it is currently 44 pages long–but this post was more an excuse for me to dialogue how I got over a series of difficult game development hurdles. While it is tempting to work on my other projects, which don’t end up stumping me on seemingly basic implementation issues, I am glad I have continued to work on this game, & learning PurrNet and Unity NGO will absolutely be helpful to me in future work.

Leave a comment