- Home /
Question by
awwilhelm · Mar 07, 2016 at 11:07 AM ·
networkingmultiplayer networking
Trouble connecting NetworkManager through script.
Hey everyone, When I call StartupHost() it is supposed to create a host, but the print in my function reads "hostId: -1 connectionId: 0 isReady: False channel count: 0". I would think that the hostId should be positive, but I don't know what would have gone wrong. Then when I call JoinGame the print, prints NULL. Am I missing something? I have spent the last 5-8 hours looking on the internet and have found nothing. Anything helps!
public void StartupHost(){
SetPort();
NetworkClient nC = NetworkManager.singleton.StartHost();
print(nC.connection);
ClientScene.Ready(nC.connection);
ClientScene.AddPlayer(client.connection, pId++);
}
public void JoinGame()
{
SetIPAddress();
SetPort();
NetworkClient nC = NetworkManager.singleton.StartClient();
print(nC.connection);
//ClientScene.Ready(nC.connection);
//ClientScene.AddPlayer(client.connection, pId++);
}
void SetIPAddress()
{
NetworkManager.singleton.networkAddress = "localhost";
}
void SetPort()
{
NetworkManager.singleton.networkPort = 7777;
}
public override void OnStartClient(NetworkClient client)
{
base.OnStartClient(client);
print("on start client");
print(client.connection);
print(this.client.connection);
//ClientScene.Ready(client.connection);
//ClientScene.AddPlayer(client.connection, pId++);
}
Comment
Your answer
Follow this Question
Related Questions
Unity Matchmaking not working on different routers. 1 Answer
[UNET LLAPI] Appending data to disconnect events 0 Answers
Multiplayer tank game 0 Answers
How do you use SetDirtyBit ? 0 Answers
Setup Custom Multiplayer Joining 0 Answers