#Bot Problem

7 messages · Page 1 of 1 (latest)

deep fog
#

It is a 1vs1 turn based game btw and I spawn network objects like this:

// FOR BOTS
GameObject aiObject = InstantiateAIByMode(matchInfo.gameMode, subMode);
AIController aiController = aiObject.GetComponent<AIController>();
#pragma warning disable 618
aiObject.GetComponent<NetworkMatchChecker>().matchId = matchId;
#pragma warning restore 618
NetworkServer.Spawn(aiObject);

// FOR REAL PLAYER
GameObject player = Instantiate(NetworkManager.singleton.playerPrefab);
#pragma warning disable 618
player.GetComponent<NetworkMatchChecker>().matchId = matchId;
#pragma warning restore 618

    NetworkServer.AddPlayerForConnection(ownerConn, player);
    matchController.player1 = ownerConn.identity;
    matchController.player2 = aiObject.GetComponent<NetworkIdentity>();
    matchController.aiController = aiController;
thick pebble
#

Server is sending command?
They should call the contents inside command directly, rather than send a cmd to itself.

If you dont want to do that, its likely some wrong logic, and your missing hasAuthority/isOwned/isClient/isLocalPlayer check for a command call.

deep fog
#

So, do I need to duplicate those command functions or is there any other way for that? Because I use the NetworkConnectionToClient parameter that comes with Command functions. Also it does works for couple days but somehow it starts giving "Send command attempted while NetworkClient is not ready." log after some days.

deep fog
#

I find out why is the log because somehow server lost its connection to the server ( the first connection on the server was server itself ) and we were using that connection for the bots. so new problem is how do i renew that connection?

Server starts like this:

public void StartServer()
{
if (!NetworkClient.isConnected && !NetworkServer.active && !NetworkClient.active)
{
networkManager.StartServer();
networkManager.StartClient();
}
}

deep fog
#

Basically i call the StartClient again after the connection lost and its solved. Thanks

hidden badge
#

Oooof what a mess you've gotten yourself into

#

first, NetworkMatchChecker was removed like 18 months ago, replaced by Match Interest Management. Second, your "bots" are not clients, they're server-run objects, and should not be hacked into trying to be clients. If you want client bots, make a headless client build and run umpteen instances of that to simulate clients.

We can't support ancient versions of Mirror, so first step would be to upgrade to latest Mirror following the steps in #📯announcements and implement Match Interest Management and NetworkMatch components.
https://mirror-networking.gitbook.io/docs/manual/interest-management/match

Keep ChangeLog and Deprecations docs handy for updating to latest Mirror
https://mirror-networking.gitbook.io/docs/manual/general/changelog
https://mirror-networking.gitbook.io/docs/manual/general/deprecations