- Home /
Connect on Lan
Hey
I'm creating a MP game that i need to run on a local network, i got this to work using Network.Connect. the problem with this is since I'm working on a local network i should have to port forward a port for players that's also on the lan to connect to me.
Is there a way to connect to some one on a lan network without having to port forward when using unity's Network..InitializeServer?
Answer by dresing9 · Oct 02, 2012 at 10:51 AM
There is indeed!
var port : float = 25565;
Network.InitializeServer(32, port, !Network.HavePublicAddress());
Then make another client connect when he is for instance pressing a button.
if (GUI.Button (Rect (Screen.width /2-70,Screen.height / 2 + 40 ,70,20), "Connect"))
{
Network.Connect(ip, port);
}
Let me know if i am not clear, this works fine for me over almost every network i use, bot hamachi, school and home.
-dresing9
so it's the same way that you use to connect over the internet?
Your answer
![](https://koobas.hobune.stream/wayback/20220613081744im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
health system and gui update 0 Answers
Animation not playing for networked character 1 Answer
can I use one Game as Server and Client at the same time? 2 Answers
Syncronize Items over network 1 Answer