[NetCode] How to find existing Host with Client ?

Hello !

I would like to use a single button to allow a Host to be started and a Client to connect to this Host.

What I’d like to do precisely:

  • Player A clicks on the button, if there are no Host, he becomes the Host.
  • Player B clicks on the (same) button, if there are no Host, he becomes the Host, if there is a Host (Player A for instance) he connects to this Host as a Client.

Is there a simple way to achieve that ?

I’m using Unity 2021.3.9f1 and switching from UNet to NetCode (and I used to use Matchmaking to do this, but it’s not available yet for NetCode :frowning: )

Thanks <3

199897-cat-love.gif

It turned out that NetCode handles matchmaking with Relay and Lobby features.
And… it works pretty great :slight_smile: !

Tutorial available here: How to setup Global Matchmaking for Unity - YouTube

Ah thanks, that saved me much time for research:)


To everyone who reads this: Have an awesome day!