private IEnumerator InitiateRespawn(int timeout) { //Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout); yield return(new WaitForSeconds(timeout)); RpcAdjustForRespawn(); EquipmentPool.ClearPool(gameObject); SpawnHandler.RespawnPlayer(connectionToClient, playerControllerId, playerScript.JobType); }
public void RespawnPlayer() { RpcAdjustForRespawn(); var spawn = CustomNetworkManager.Instance.GetStartPosition(); var newPlayer = ( GameObject)Instantiate(CustomNetworkManager.Instance.playerPrefab, spawn.position, spawn.rotation); // NetworkServer.Destroy( this.gameObject ); EquipmentPool.ClearPool(gameObject.name); PlayerList.Instance.connectedPlayers[gameObject.name] = newPlayer; NetworkServer.ReplacePlayerForConnection(this.connectionToClient, newPlayer, this.playerControllerId); }
private IEnumerator initiateRespawn(int timeout) { Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout); yield return(new WaitForSeconds(timeout)); RpcAdjustForRespawn(); var spawn = CustomNetworkManager.Instance.GetStartPosition(); var newPlayer = Instantiate(CustomNetworkManager.Instance.playerPrefab, spawn.position, spawn.rotation); // NetworkServer.Destroy( this.gameObject ); EquipmentPool.ClearPool(gameObject.name); PlayerList.Instance.connectedPlayers[gameObject.name] = newPlayer; NetworkServer.ReplacePlayerForConnection(connectionToClient, newPlayer, playerControllerId); }
private IEnumerator InitiateRespawn(int timeout) { Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout); yield return(new WaitForSeconds(timeout)); RpcAdjustForRespawn(); EquipmentPool.ClearPool(gameObject.name); //Remove player objects PlayerList.Instance.RemovePlayer(gameObject.name); //Re-add player to name list because a respawning player didn't disconnect PlayerList.Instance.CheckName(gameObject.name); SpawnHandler.RespawnPlayer(connectionToClient, playerControllerId, playerScript.JobType); }