Matchmaking with Nakama server and establish a P2P connection

Hello, is it possible to establish a P2P connection after finding a match using Nakama server?
I saw on a old post that Nakama does not support P2P, but is there any ways to switch the connection to P2P, meaning it will only use Nakama server for matchmaking, and the match itself will be hosted by the player.

I want to create a game in Unity that has matchmaking, and after the server finds a match, i want the game to establish a P2P connection.
I found some tutorials about setting up the matchmaking system using Nakama server in Unity, but I don’t know how to make the game switch to P2P connection.
I would really appreciate if anyone can give me any ideas or explain how this would work(if it’s possible).

The reason why I want to make this a P2P connection, is because of financial reasons. This will be for a quick match, so I want to keep this as low cost as possible as I am planning to have a competitive match(with a dedicated server) later on.

I understand the negatives of P2P when it comes to online game, but since I am planning to use this connection for a quick match, rather than a competitive, I think it should be okay.

Hi @Brurixo.

One way to do this would be to have players use Nakama for matchmaking and once a match is found, have the players join a Nakama match together.

Once all players have joined, determine who the “host” player will be (we recommend sorting the match presences by Session ID and selecting the first one as the host). That host can then send whatever P2P connection data they need to send to the other players in the match (e.g. the host IP/Port etc) via match data. The other players would receive the connection data and connect appropriately using whatever P2P solution you have chosen (e.g. Netcode for GameObjects). It’s up to you whether you would want the Nakama match to continue at this point to facilitate other tasks such as keeping score etc or if you want to just close it.

Alternatively you could have the matched players form either a Party or a temporary Group to achieve the same result. A party would allow players to send data just like a match using the Party Data Send methods, whereas a Group would allow metadata to be stored directly by the group creator (i.e. the host) so they could store the P2P connection details there instead.

Broadly speaking there are many ways to facilitate this depending on your needs.

I hope this helps.