How do switch a project to Nakama that has been designed using NetworkManager and NetworkBehavours

I have been designing a turn-based PvP game for years, and recently the service I was using for multiplayer stopped being supported. It worked using a NetworkManager and NetworkBehaviours, and I used mirror to relay everything. I’m looking for a new multiplayer option, and I came across Nakama, but I see that it doesn’t use a NetworkManager. Is there a way to easily swap my project over to the Nakama system, or will I have to redesign my whole multiplayer framework, including all my cmd and rpc commands?

Hi @trevaur,

Could you share which service you were using that’s no longer supported? That would help in suggesting the best path.

It won’t be a drop-in swap, since Nakama doesn’t have NetworkManager/NetworkBehaviour-style object replication, but you shouldn’t need to redesign your game either. The closest equivalent to what you describe is the Nakama relayed model: Client Relayed Multiplayer - Heroic Labs Documentation

In relayed matches, clients send opcode-tagged messages that Nakama forwards to the other players. So you could wrap the Nakama client in a thin layer that keeps your Command/Rpc-style calls and turns each one into a message with its own opcode. Your game logic and UI would stay as they are. Two things to plan for: relayed matches have no built-in host, so you’d designate one client (e.g. the match creator) to play that role, and anything Mirror synced automatically (SyncVars, spawns) would need to become explicit messages, which for a turn-based game is usually just moves plus an occasional state snapshot.

There’s also an older thread on using Nakama with Mirror that may be useful: Nakama x Unity Mirror

Best

Thanks for your reply! I was using NobleWhale. I checked out that earlier thread, but didn’t find it super useful.

I found an article about using Mirror and Nakama, and it seems like the kind of approach I’m looking for, but it is somewhat incomplete: Nakama Unity Mirror: Build Secure Multiplayer Games - DrCodes

They provide an override to StartHost in their NakamaNetworkManager that inherits from NetworkManager, which looks good, but how would that work in the context of matchmaking? Obviously, you would only want to call StartHost if a new game was being created, and not when joining another player’s game. It seems like I would want a “Find Match” button the player can press, and if there is an available game to join I would run StartClient as a callback to connect to the existing host, and if there are no available games I would run StartHost as a callback, and run Nakama’s CreateMatch within that callback.

Is this sort of design possible? I’m only basing this idea off that article I linked, with the assumption that they know what they’re talking about, which might not be true. I do know that when I was using NobleWhale, once the players were connected then I could completely switch over to Mirror, is that not the case with Nakama?

Important to note I’m not concerned at the moment with cheating, this is purely for playtesting.

Yes it’s possible, what you describe is a common pattern using the match create and match listing API.