thanks so much!!! that was perfect!!! Now I am running into another issue though. I try to instantiate my prefab but it tells be there is no connection to the server. But the this is I run the code below and it gets through my nests if statements every time. The most odd part is that everything seems to work until I get to my instantiate.
public void SetupServer()
{
NetworkServer.Listen(4444);
isAtStartup = false;
int x = 0;
while (x == 0)
{
if (NetworkServer.active)
{
Debug.Log("Server Connected");
x = 1;
}
}
}
public void SetupClient()
{
myClient = new NetworkClient();
myClient.RegisterHandler(MsgType.Connect, OnConnected);
myClient.Connect("127.0.0.1", 4444);
myClient.RegisterHandler(MsgType.Connect, OnConnected);
ClientScene.RegisterPrefab(playerPrefab);
isAtStartup = false;
}
// Create a local client and connect to the local server
public void SetupLocalClient()
{
myClient = ClientScene.ConnectLocalServer();
myClient.RegisterHandler(MsgType.Connect, OnConnected);
isAtStartup = false;
}
// client function
public void OnConnected(NetworkMessage netMsg)
{
Debug.Log("Connected to server");
int x = 0;
while (x == 0)
{
if (myClient.isConnected)
{
Network.Instantiate(playerPrefab, new Vector3(6f, 0.6f, 4.5f), Quaternion.identity, 0);
x = 1;
}
}
}