- Home /
Why do I get "Spawned object not found" when a player disconnects and remaining players try to communicate?
Simple 2D game - nothing is spawned except players when host or clients started. In this example, I had 3 players connected. I closed window to test disconnecting. OnServerDisconnect was invoked on host, which set that player's state to disconnected. No problem so far. In Unity window, I see disconnected player disappear; host and other player still there.
When remaining player tries to commuicate with host, I get Spawned object not found for any subsequent communication attempts (via Cmd or TargetRPC calls which normally work). In this test case, remaining player attempted to command the host to provide tourney info:
public void GetTourneyInfo(string pName) // Player requests...
{
Debug.Log("Calling CmdGetTourneyInfo");
CmdGetTourneyInfo(pName); // MyPlayer.cs:377
}
[Command(requiresAuthority = false)]
public void CmdGetTourneyInfo(string name)
{
Debug.Log("CmdGetTourneyInfo - calling RequestTourneyInfo(name) " + name);
Dodeo.instance.RequestTourneyInfo(name);
}
[TargetRpc]
public void TargetRpcTourneyInfo(NetworkConnection pConn, string tInfo)
{
tInfo += " "; // Ensure string is not null
Dodeo.instance.DisplayHelp(tInfo, false);
}
Error details: Spawned object not found when handling Command message [netId=4] UnityEngine.Debug:LogWarning (object) Mirror.NetworkServer:OnCommandMessage (Mirror.NetworkConnectionToClient,Mirror.CommandMessage,int) (at Assets/Mirror/Runtime/NetworkServer.cs:943) Mirror.MessagePacking/<>c_DisplayClass6_0`2:b_0 (Mirror.NetworkConnection,Mirror.NetworkReader,int) (at Assets/Mirror/Runtime/MessagePacking.cs:126) Mirror.NetworkServer:UnpackAndInvoke (Mirror.NetworkConnectionToClient,Mirror.NetworkReader,int) (at Assets/Mirror/Runtime/NetworkServer.cs:455) Mirror.NetworkServer:OnTransportData (int,System.ArraySegment`1,int) (at Assets/Mirror/Runtime/NetworkServer.cs:518) Mirror.LocalConnectionToServer:Send (System.ArraySegment`1,int) (at Assets/Mirror/Runtime/LocalConnectionToServer.cs:45) Mirror.NetworkConnection:Send (Mirror.CommandMessage,int) (at Assets/Mirror/Runtime/NetworkConnection.cs:137) Mirror.NetworkBehaviour:SendCommandInternal (string,Mirror.NetworkWriter,int,bool) (at Assets/Mirror/Runtime/NetworkBehaviour.cs:249) MyPlayer:CmdGetTourneyInfo (string) MyPlayer:GetTourneyInfo (string) (at Assets/Scripts/MyPlayer.cs:377) Dodeo:ClickRightButton () (at Assets/Scripts/Dodeo.cs:1595) UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)