How to use Nakama's Server Framwork and a Unity game server?

hi.

im working on a game that everything should be handled by unity at the server. i need to know how can I do things using both nakama and unity. for example, ı need the match makıng to be done by nakama and after some condıtıon, that match starts players just be able to send inputs and nakama send it to unity instance and get a new snapshot to the unity and send them to players. and after end of the match remove unity match instance.

What you are pointing out as a strategy sounds almost valid. You can spawn headless instances of your game per Nakama match and then destroy each instance after each match is concluded.
However, the usage of the Nakama server as a relay between unity instance and players in a way that players send input to Nakama and Nakama relays that to the headless instance, does not seem necessary (unless you are planning on doing something I cannot think of right now). When you create a headless instance, you can inform the players via Nakama to connect to the socket (IP: Port) the headless server is listening to. This gives you options as to use UDP, for example, for sending input from players to the headless server. When the headless server decides the match is concluded, it can use Nakama API (just like player unity clients) to tell the current match to close; This can be used to calculate whether the match was concluded successfully, whether some of the players abandoned the match, how much XP each player gets, etc.

1 Like

@Mahdad-Baghani thank you for the informative reply. I’m looking to instantiate and remove server match instances for performance and flexibility but I think it’s a very error-prone approach. by your approach, we will have a limited and fixed number of server matches for the game. for example, in games like clash royale or clash of clans, there should be an unlimited number of matches pooled on the server.

@virtouso I think the example of Clash Royale you give is not a good one for your use case. You mentioned you want to use a full physics simulation server side (aka Unity headless instances) and yet Clash Royale does not do that at all. They have a lightweight deterministic layer with the usual mixture of positional updates and command messages as part of their netcode protocol.

In fact Nakama server’s authoritative multiplayer engine was specifically inspired by the “Clash Royale model” to support many thousands of matches running for players. Why do you want to use Unity engine on the server side at all? Can you describe your game’s multiplayer design in more detail?