- Home /
Multiplayer - Can't Connect Me ?
Hi...
I created a MultiPlayer game .
when my friend create a game I can join him directly , but when he trying to join my created game , it's not working.
I think the problem from my PC ( Antivirus Or FireWall ) , but am not sure.
please any idea where is the problem and how can I fix it ?
thank you :)
Need more information of how the multiplayer part is scripted and physically set up. Do you have a master server? On the same network etc.?
function StartServer(ServerName:String ,ServerPassword:String ,$$anonymous$$axPlayers:int)
{
$$anonymous$$atchName = ServerName;
$$anonymous$$atchPassword = ServerPassword;
$$anonymous$$axPlayersCount = $$anonymous$$axPlayers;
Network.InitializeServer($$anonymous$$axPlayersCount, NetworkPort , true); // false = Not useing internet
$$anonymous$$asterServer.RegisterHost(RegisterHostName,$$anonymous$$atchName,"");
}
function OnServerInitialized()
{
Server_PlayerJoinRequest(PlayerName,Network.player);
}
function OnConnectedToServer()
{
networkView.RPC("Server_PlayerJoinRequest",RPC$$anonymous$$ode.Server,PlayerName,Network.player);
}
@RPC
function Server_PlayerJoinRequest(PlayerName : String , view : NetworkPlayer)
{
networkView.RPC("Client_AddPlayerToList",RPC$$anonymous$$ode.All,PlayerName,view);
}
@RPC
function Client_AddPlayerToList(PlayerName : String, view : NetworkPlayer)
{
// If there same name //
for ( var pl : $$anonymous$$PPlayer in PlayerList)
{
if ( pl.PlayerName == PlayerName)
{
PlayerName = PlayerName + Random.Range(1,250);
}
}
var tempplayer : $$anonymous$$PPlayer = $$anonymous$$PPlayer();
tempplayer.PlayerName = PlayerName;
tempplayer.PlayerNetwork = view;
PlayerList.Add(tempplayer);
Player$$anonymous$$anagerPrefab.name = PlayerName;
if ( Network.player == view )
{
$$anonymous$$yPlayer = tempplayer;
var play : GameObject = Network.Instantiate(Player$$anonymous$$anagerPrefab,Vector3.zero, Quaternion.identity,5) as GameObject;
play.name = PlayerName;
$$anonymous$$yPlayerObject = play;
}
}
function OnPlayerConnected(player : NetworkPlayer)
{
for ( var pl : $$anonymous$$PPlayer in PlayerList )
{
networkView.RPC("Client_AddPlayerToList",player,pl.PlayerName,pl.PlayerNetwork);
}
networkView.RPC("Client_Get$$anonymous$$ultiplayer$$anonymous$$atchSettings",player,Current$$anonymous$$ap.$$anonymous$$apName,"","");
}
function OnLevelWasLoaded ()
{
if (Application.loadedLevelName == Current$$anonymous$$ap.$$anonymous$$apLoadName && Network.isServer)
{
$$anonymous$$atchLoaded = true;
Spawnpoints = GameObject.FindGameObjectsWithTag("spawnpoint");
networkView.RPC("Client_ServerLoaded",RPC$$anonymous$$ode.AllBuffered,If$$anonymous$$atchStarted);
}
}
it's work fine when I connect to other PC , but when friends trying to connect my PC it's not working....
Answer by WizzDE · Aug 03, 2013 at 09:47 PM
Check if...
you forwardted the right port on your router
he is using your public ip (google for myip)
your/his firewall isn't bloking your game
you didn't made any codding mistakes
hope I helped!
Wizz
Thank u , are there any thing I can do it by program$$anonymous$$g , like let the firewall don't stop my game , or any thing else .
note : some times my friend can join me even I create the game.
that's really weird, Why some times work and other don't ?
The point of a firewall is to block programs from unauthorized usage of the network. You can't "allow yourself" that would make the firewall pointless. Also if you're behind a NAT router (which you propably are) that doesn't "support" / allow NAT punchthrough, you need to forward the port you're using to your PC. That's all external problems which are not related to your application and therefore can only be solved outside your application.