- Home /
UNET ReplacePlayerForConnection problem
SOLVED:
Hey guys, I am from Germany so I am sorry for my bad englisch.
I want to replace the Player-Object with a PlayerDead-Object when the players health reaches 0.
The server is checking the health of the player and is running the code below:
[Command]
void CmdRespawnPlayer ()
{
GameObject go = Instantiate (playerDeadPrefab, Vector3.zero, Quaternion.identity) as GameObject;
NetworkServer.Spawn (go);
NetworkServer.ReplacePlayerForConnection (connectionToClient, go, 0);
NetworkServer.Destroy (gameObject);
}
When I host a LAN-Game and the player dies, the new deadPlayerPrefab spawns and changes to the new object. BUT when I connect with a second client with the same computer and player 1 dies, player 2 is changing his playerObject too. (The old Player-Object 2 is retained)
What is the Problem? maybe is there a problem with 'connectionToClient' ?
Thanks for you help ;)
Dear Dosenbiiir
I solved the problem:
I forogtt to deactivde the camera of the deadPlayer-Object on the second client.
Your answer
Follow this Question
Related Questions
Problem| Player Name Above The Player 2 Answers
Network disconnect player 1 Answer
What is the CCU of the default Unity Networking? 1 Answer
Target = NetworkedMe 1 Answer