Search Unity

How generae a random IPAdress for the hots?

Discussion in 'Multiplayer' started by HumphreyGames, Dec 15, 2020.

  1. HumphreyGames

    HumphreyGames

    Joined:
    May 5, 2020
    Posts:
    40
    Hi!

    I am making a lobby using dapper dino's tutorial series (
    )

    I have made the lobby but i am wondering about the IPAdress. How can I make it so that the host can have their own IPAdress (it generates a random one every time) instead of only using "Localhost".

    I don't know if this is even possible using mirror but any help would be great!

    Thanks,
    Josh
     
    Last edited: Dec 15, 2020
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Well the network interface needs to already have the IP address configured for use by the operating system, and it needs to be on the same subnet range as the rest of the local network. So I don't think you want a "random" IP address, because that won't be useful. You want the IP address of the network interface.

    But that will only get you the address needed on the local network for it to work if you're behind a NAT router. Instead what you'd want in that case is the external IP address of the router, and then configure port forwarding on it.

    But yet again.... What you'd probably do in reality is get a dedicated server, so you can buy a domain name for it, and then you can hard code that domain name into your game to connect to. So the player never actually has to enter any address. It just connects to your dedicated server.
     
    Last edited: Dec 15, 2020
  3. HumphreyGames

    HumphreyGames

    Joined:
    May 5, 2020
    Posts:
    40
    Thanks for the reply, i will try this :)