Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Called when the player clicks the respawn button
- [Client]
- public void respawnClick()
- {
- CmdRespawnClick();
- }
- [Command]
- public void CmdRespawnClick()
- {
- var spawn = NetworkManager.singleton.GetStartPosition();
- if(charSelect.selectedChar == 1) //If character 1 is selected
- {
- GameObject player = Instantiate(Resources.Load("Characters/Player1", typeof(GameObject)), spawn.position, Quaternion.identity) as GameObject;
- NetworkServer.DestroyPlayersForConnection(NetworkManager.singleton.client.connection);
- NetworkServer.ReplacePlayerForConnection(connectionToClient, player, 0);
- }
- else if(charSelect.selectedChar == 2) //If character 2 is selected
- {
- GameObject player = Instantiate(Resources.Load("Characters/Player2", typeof(GameObject)), spawn.position, Quaternion.identity) as GameObject;
- NetworkServer.DestroyPlayersForConnection(NetworkManager.singleton.client.connection);
- NetworkServer.ReplacePlayerForConnection(connectionToClient, player, 0);
- }
- //Waits for a moment to de-activate the respawn button
- StartCoroutine(WaitForRespawn());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement