UNET - Both client and server player disappears for client after scene load
This is getting me crazy. I searched in all questions made about this error, and NONE of them solved my problem.
The problem is : when the host creates match in different scenes, it works for host. But when client tries to join the match, client joins match but in default scene for some seconds, then it loads the host scene after some seconds, then, when the client loads host scene, all players(including server and client) disappears for the client, but i can see client player at server, and the client get the errors at console :
"did not find target for sync message for 2" "did not find target for sync message for 1" "a connection has already been set as ready"
Here is the code :
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) {
var player = (GameObject)GameObject.Instantiate(playerPrefab, FindObjectOfType<NetworkStartPosition>().transform.position, FindObjectOfType<NetworkStartPosition>().transform.rotation);
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
}
public override void OnClientConnect(NetworkConnection conn){
if (!clientLoadedScene)
{
ClientScene.AddPlayer(conn, 0);
}
}
public override void OnClientSceneChanged(NetworkConnection conn){
ClientScene.Ready(conn);
ClientScene.AddPlayer(conn, 0);
}
Your answer
Follow this Question
Related Questions
How should I verify that all of my client Object are created and ready after loading a new scene? 0 Answers
Adding Clients after Log in 1 Answer
NetworkServer.Send and NetworkClient.Send or synchronising on player prefab? 0 Answers
Issuing SetClientReady causes duplicate network objects on local client 1 Answer
[UNET] Transform sycing problem,[UNET] TRANSFORMATION SYCING PROBLEMS 0 Answers