/// <summary> /// Override this method if you want to customize paddle spawning /// </summary> protected virtual void spawnPaddles() { // Paddle 1 - Positioned on the left ulong clientId = NetworkingManager.Singleton.ConnectedClientsList[0].ClientId; leftPaddle = Instantiate(paddlePrefab, Vector3.zero, Quaternion.identity); leftPaddle.GetComponent <NetworkedObject>().SpawnWithOwnership(clientId); leftPaddle.init(true); leftName = network.getConnectedPlayerNames()[clientId]; if (useBot) { // Bot - Positioned on the right rightPaddle = Instantiate(paddlePrefab); rightPaddle.GetComponent <NetworkedObject>().Spawn(); rightPaddle.setupBot(); rightPaddle.init(false); rightName = "Bot"; } else { // Paddle 2 - Positioned on the right clientId = NetworkingManager.Singleton.ConnectedClientsList[1].ClientId; rightPaddle = Instantiate(paddlePrefab, Vector3.zero, Quaternion.identity); rightPaddle.GetComponent <NetworkedObject>().SpawnWithOwnership(clientId); rightPaddle.init(false); rightName = network.getConnectedPlayerNames()[clientId]; } }
/// <summary> /// Override this function to customize what happens when the game quits. /// Make sure to unspawn network objects. /// </summary> /// <param name="clientId"></param> protected virtual void endGame() { // Unspawn paddles and other things leftPaddle.GetComponent <NetworkedObject>().UnSpawn(); Destroy(leftPaddle.gameObject); rightPaddle.GetComponent <NetworkedObject>().UnSpawn(); Destroy(rightPaddle.gameObject); // Remove callbacks NetworkingManager.Singleton.OnClientDisconnectCallback -= clientDisconnectCallback; NetworkSceneManager.SwitchScene("Lobby"); }