Hi , i’m sorry ,it seems to be so simple but i 'm a beginner in networking and i didn’t find any answer for that :
i want my first app user to be automatically the server and then all others will be clients , i use MLAPI system
that’s the code i tried but it didn’t work :
private void Awake()
{
MakeSingleton();
SetupParamsFromPrefs();
SetupConnection();
}
private void SetupConnection()
{
if (NetworkManager.Singleton.ConnectedClientsList.Count > 0)
{
Debug.Log("there are alraedy clients ,we start as a client");
StartNetworkClient();
}
else
{
if (NetworkManager.Singleton.NetworkConfig.ConnectionApproval)
{
Debug.Log("there s already a server , we start as client");
StartNetworkClient();
}
else
{
Debug.Log("there is no client , we start as serverserveur");
StartNetworkServer();
}
}
}
public void StartNetworkClient()
{
if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsClient)
{
return;
}
else
{
NetworkManager.Singleton.StartClient();
}
}
public void StartNetworkServer()
{
if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsClient)
{
return;
}
else
{
NetworkManager.Singleton.StartServer();
}
}
Thanks in advance for your help , i guess i missed something …