- Home /
UNet SpawnWithClientAuthority Network Connection
I want to respawn my player by creating a new Player object when they die. I want to use the method NetworkServer.SpawnWithClientAuthority to spawn my player with Authority. I call this function through a command, here is the code I use,
[Command]
void CmdRespawn()
{
GameObject _NewPlayer = (GameObject)Instantiate(player, Vector3.zero, Quaternion.identity);
NetworkServer.Destroy(this.gameObject);
NetworkServer.SpawnWithClientAuthority(_NewPlayer, connectionToClient);
}
My question is how do I get the NetworkConnection (which is a paramter) of the client for SpawnWithClientAuthority. connectionToClient just returns null, connectionToServer returns null. I cant figure out how to get the connection.
Thanks for the help in Advance.
Your answer
Follow this Question
Related Questions
Networking | Getting buffered other - previous spawned players 1 Answer
NetworkMatch.DropConnection not executing callback 0 Answers
Networking: How to spawn dynamically created objects 2 Answers
Networking with a modem, without connecting to a server... Is it possible, are there any examples? 1 Answer
Network.Spawn. Not Spawned on clients except for host. 0 Answers