March 2nd, 2024

This week in Synthicate I was able to add multiplayer remote procedure calls (RPCs) and configure the ability for players to join a game lobby and send their custom names. In the recent set of pushes from Friday, I fixed some functionality that updates the number of players that show up in the lobby (oshears/Synthicate@b3735cb).

One main issue that I ran into trying to implement this was attempting to initiate ClientRPC calls before the clients were fully configured. Apparently in Unity it takes the clients a moment to fully get setup, event after the server successfully connects with them. Thus, if the server sends out a ClientRPCs, but the client is not ready, then it will not receive the RPC successfully. This form post helped me to identify the issue, however I am still looking for a method or event that is trigger once the client is fully setup and ready to receive RPCs from the server.

Recently I have been very satisfied with my progress on learning about using Unity’s serialization to link GameObjects to one another. In the past I relied on the find with tags feature or the Resource.Load() method to get game objects and assets, but after learning that I can use serialization and link GameObjects with one another from the editor, my productivity has taken a sharp increase.

I’ve also put a lot of work into setting up a state machine for the Game Manager to work with. This allows the code to be substantially more modular, with each state only containing code that is relevant to the state the Game Manager is in. In the coming week I am to work on building out the actual functional states of the game now that I have the multiplayer synchronization logic setup.

The next goal I am to work on is getting the setup state to work across the clients. Once all of the players join the game, the host can start the game and will send an RPC call that lets the clients know that the game has begun. The host will then start with their setup phase, which lets the host place to select a place for their first outpost and road to be built. In future versions it would be nice to randomize this functionality and allow a random player to be the first to start building. In Settlers of Catan, choosing where to place your first outpost is a pretty big step that can set you up for success or for failure for the rest of the game. For now though, once the host player places their initial outpost and road, the next client to join the game will then proceed with their setup phase. After all players have place their initial outposts, the last client will have the chance to place their second initial outpost. From there, the order continues in reverse until the host is the last to place their second outpost and road. After this, game is now ready to officially begin!

I believe that I can get this setup phase working in a couple of hours. There are a lot of cool features I’d like to add, including visually seeing the number for the dice being generated. In Synthicate, I call this process “hashing” as an allusion to hashing something out, and also to the process of hashing in computer science. For now though, instead of implementing this, I’d like to focus on getting the core gameplay working, especially with multiplayer. This includes: getting resource distributions working, getting player build modes working, and processing player victory points and win conditions.