Development Log #2 - Syncing Network Objects


Welcome to my second dev log for PolyShift!

In this dev log, I’ll cover the challenges and progress I made while implementing health bars for both players and enemies in PolyShift. Health bars might seem like a simple feature, but in a multiplayer game with Unity’s Netcode for GameObjects, they turned into a surprisingly complex task! When I started implementing health bars, I initially focused on making them work for players. While the first-person health bar displayed and updated correctly, the isometric health bar was a whole different story. The health values updated on the host, but non-host clients didn’t see any changes. This was when I realized I had a lot to learn about network synchronization and permissions in Netcode.

At the same time, I started working on enemy health bars, aiming to show them to all players across the network. However, only the host could damage enemies, and their health bars refused to disappear upon death for non-host clients. These bugs completely broke the immersion and functionality of the game.

On the more technical side of things, I was using a network variable to represent the player's health value but I was not fully informed on not only the full capabilities of a network variable but also its restrictions. My main issue was the fact that the variable was getting properly updated however, the health bar itself was not. I eventually fixed this issue by discovering the magic of network variables. Network variables inherently come with an event called OnValueChanged that automatically sync the variable's properties over the network. I added an event that updates the health bar every time OnValueChanged is called. This must have fixed the issue right? Wrong! As it turns out, the bug was a result of two different issues. Network variables also come with restrictions that you can modify through its constructor. Setting its read and write permissions to the proper values is what eventually solved this week-long bug.

With both player and enemy health bars working across the network, Polyshift took a big step forward. Players can now see health bars update in real-time in both first-person and isometric views, while enemies’ health bars appear and disappear correctly for all clients. These small details bring the game closer to feeling polished and immersive. 

Stay tuned for the next dev log, where I’ll share more about the challenges and progress in creating abilities, effects, and game flow logic in Polyshift. Thanks for reading!

Get PolyShift

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.