I’m currently using this in order to give each player a unique ID.
GetComponent<NetworkIdentity> ().netId;
Which works, but if I respawn the player by destroying and re-instantiating, they spawn with a new ID. (which I’m doing like so)
var spawn = NetworkManager.singleton.GetStartPosition();
var newPlayer = ( GameObject) Instantiate(NetworkManager.singleton.playerPrefab, spawn.position, spawn.rotation );
NetworkServer.ReplacePlayerForConnection( connectionToClient, newPlayer, playerControllerId );
NetworkServer.Destroy( gameObject );
So I’m really not sure how to fix this. I’m aware I could have a dead boolean and reset positions instead of actually respawning, but since I’m trying to have multiple classes you can spawn as, I need to re-instantiate every time.
Any ideas? Or could someone share how they did it in their own game?