How to set hosts IP

So, I made a 2D game with the basics of Roll-a-Ball and Multiplayer Networkig tutorials.

The problem is: on one-computer (two clients: one is the host) it works fine, but my friend cant connect to me. I think the problem is that the NetworkManagerHUD always reads the address as “localhost” and port “7777”. Can I change it? And how?

Oh, I know how to change it, but in-game? Or can I add a button to change it?

You can change the address that the NetworkManager connects to by setting networkAddress in your code any time before the call to StartClient(). You shouldn’t need to set it on the host.

You’re still going to have trouble connecting to any host behind a router though due to those pesky “forwarding” issues. You have two options.

Option 1 is to use Unity’s expensive relay servers. That means you’ll need to use unity’s matchmaking stuff. NetworkMatch.CreateMatch() / NetworkMatch.ListMatches() / NetworkMatch.JoinMatch(). Then instead of setting NetworkManager.networkAddress you just pass the match info JoinMatch() to connect.

Option 2 is some sort of NAT traversal solution that will handle port forwarding / punch-through automatically. I recommend my plugin that you can get on the asset store: Unity Asset Store - The Best Assets for Game Making
In that case you won’t have to worry about creating or joining matches. You just call StartHostAll() to start hosting. You pass the host IP into StartClientAll() to connect. Everything else is handled for you behind the scenes. Ports are forwarded automatically on the host’s router, and if that doesn’t work there’s some complicated puchthrough magic that happens that will usually (85-95%) succeed in connecting players directly. If all else fails you can optionally still fall back to using Unity’s relay servers which work 100% of the time (but are expensive).

hey, Buddy,How do you solve this problem in the end?