Hi,
What I would like:
- First client starts the game. It sees that there is no server available, so it starts the game as host.
- All other clients connect to the existing host
- If the host leaves the game, another client becomes the host automatically.
What I’ve tried:
void Update()
{
if (NetworkServer.active == false)
{
Debug.Log("NetworkServer inactive.");
if (NetworkClient.active == false)
{
Debug.Log("NetworkServer and NetworkClient inactive. Starting as host.");
//m_Manager.StartHost();
}
}
else
{
Debug.Log("NetworkServer active.");
if (NetworkClient.active == false)
{
Debug.Log("NetworkServer active and client inactive. Connecting as client.");
//m_Manager.StartClient();
}
}
}
So far it’s telling me that the server is inactive on both clients, although one of them has started a local host. Manually connecting and all of those things work fine. Is “NetworkServer.active” only true for the local instance? Do I need to somehow test the connection to find out if the server exists on the network instead?
Is this approach viable at least for debugging and testing during development? Our project will have its own dedicated server later, but we don’t have access to it until a few months.
Thanks!