I am getting the below error.
I am using Mirror version 44.0.2.
Unity version 2020.3.10f1
This is happening when I try to call the player in RTSNetworkManager.
The below line works fine:
Players.Add(player);
Then if I try to call:
player.SetDisplayName($“Player {Players.Count}”);
or:
player.SetPartyOwner(Players.Count == 1);
I get the error.
This means I will either get the error when I try to host a lobby. I then can not start a game, as the conn.identity has been disconnected.
I wonder if I made an error in an earlier script that is causing this, but it seems to be built in to mirror to prevent exploits.
Disconnecting connId=0 to prevent exploits from an Exception in MessageHandler: NullReferenceException Object reference not set to an instance of an object
at RTSNetworkManager.OnServerAddPlayer (Mirror.NetworkConnection conn) [0x00029] in \Documents\UnityRepos\RealTimeStrategy\Assets\Scripts\Networking\RTSNetworkManager.cs:69
at Mirror.NetworkManager.OnServerAddPlayerInternal (Mirror.NetworkConnection conn, Mirror.AddPlayerMessage msg) [0x00060] in \Documents\UnityRepos\RealTimeStrategy\Assets\Mirror\Runtime\NetworkManager.cs:1128
at Mirror.MessagePacking+<>c__DisplayClass6_02[T,C].<WrapHandler>b__0 (Mirror.NetworkConnection conn, Mirror.NetworkReader reader, System.Int32 channelId) [0x0007a] in \\Documents\UnityRepos\RealTimeStrategy\Assets\Mirror\Runtime\MessagePacking.cs:118 UnityEngine.Debug:LogError (object) Mirror.MessagePacking/<>c__DisplayClass6_0
2<Mirror.AddPlayerMessage, Mirror.NetworkConnection>:b__0 (Mirror.NetworkConnection,Mirror.NetworkReader,int) (at Assets/Mirror/Runtime/MessagePacking.cs:122)
Mirror.NetworkServer:UnpackAndInvoke (Mirror.NetworkConnectionToClient,Mirror.NetworkReader,int) (at Assets/Mirror/Runtime/NetworkServer.cs:430)
Mirror.NetworkServer:OnTransportData (int,System.ArraySegment1<byte>,int) (at Assets/Mirror/Runtime/NetworkServer.cs:484) Mirror.LocalConnectionToServer:Send (System.ArraySegment
1,int) (at Assets/Mirror/Runtime/LocalConnections.cs:88)
Mirror.NetworkConnection:Send<Mirror.AddPlayerMessage> (Mirror.AddPlayerMessage,int) (at Assets/Mirror/Runtime/NetworkConnection.cs:135)
Mirror.