Hello there! I'm trying to replace the player object for the connection of a client, but the connection seems to be null?
I tried following this forum post (https://forum.unity.com/threads/connectiontoclient-is-null.483886/), and this GitHub issue (https://github.com/MirrorNetworking/Mirror/issues/3105)
Making the replace function a command seemed to get me a bit further, but still don't have the desired behaviour. Here's my code:
[Command(requiresAuthority = false)]
public void CmdReplacePlayer(GameObject newController)
{
NetworkManagerSchabby.singleton.ReplacePlayer(GetComponent<NetworkIdentity>().connectionToClient, newController);
}
public void ReplacePlayer(NetworkConnectionToClient conn, GameObject newPrefab)
{
Debug.Log(conn);
Debug.Log(conn.identity);
Debug.Log(conn.identity.gameObject);
GameObject oldPlayer = conn.identity.gameObject;
NetworkServer.ReplacePlayerForConnection(conn, Instantiate(newPrefab), true);
Destroy(oldPlayer, 0.1f);
}
The error: