Two players, one map

Fiber is meant to be played with up to four friends, so multiplayer can’t be an afterthought. On Monday night, for the first time, two copies of the game shared a map: one hosted a session, the other found it in a list and joined.

The first test: host a session from the multiplayer dashboard, wait, and a second player drops in

Three layers

The design we wrote up in March splits multiplayer into three layers:

Host-authoritative keeps the rules in one place. Only one machine decides whether a hit landed or what an enemy does next, and everyone else draws what the host says happened.

The first pass

Stephen Cassidy built most of the first layer of networking: a network manager that signs in to Nakama, a session manager for the peer lifecycle, a player manager that spawns one player per connection, input sent over RPCs, a bridge that replicates combat events, and mob sync with the host running the AI. He also got Nakama running locally in Docker with seed data, so neither of us needs a server to work on it.

Testing without Steam

The plan routes sign-in and lobbies through Steam, which made it hard to test two copies on one machine or between two dev machines. So I refactored it to work without Steam:

What broke first

Getting two players on screen was mostly a list of small, specific bugs:

Most of these fixes came with tests, and the multiplayer code now logs heavily, which made each new bug much faster to track down. Next is making every single-player feature behave when there’s more than one of you.

← More posts