Search Unity

Question How to create a game with a listen server / host architecture ?

Discussion in 'Netcode for GameObjects' started by osgseb, Mar 23, 2023.

  1. osgseb

    osgseb

    Joined:
    Jan 17, 2022
    Posts:
    26
    Hello,

    I just came accros this page in the documentation which explains the different options to a listen server / host architecture but I was wondering how do you actually set-up/configure this ? I'll would like to make some experiments which involved clients not being in the same local network and I'd like not using a dedicated or relay server.

    Thanks
     
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @osgseb , all you need to do is invoke NetworkManager.Singleton.StartServer(); from a method to run start the server.

    You can then connect through direct ip with StartClient once you get the public IP of the server. keep in mind that your connection will fail most of the time if you're not using dedicated servers or relay, because firewalls tend to block connections coming "out of the blue".
     
    osgseb likes this.