//when called after pressing 'B', it decides whether the ball respawns at the north or south respawn point public void RandomInsert() { int number = 0; number = Random.Range(1, 3); if (number == 1) { spawnScriptNorth.Respawn(); } else { spawnScriptSouth.Respawn(); } }
void Switches() { RaycastHit hit; Ray screenray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(screenray, out hit, switchRange)) { BallRespawn ball = hit.transform.GetComponent <BallRespawn>(); Debug.Log("Not working"); if (ball != null) { Debug.Log("isWorking"); ball.Respawn(); } } }
void OnTriggerStay(Collider other) { if (other.gameObject.CompareTag("Ball")) { Destroy(other.gameObject); //call AddScore to add 1 point to P2 gameController.AddScore("P1"); gameController = Game_Controller.GetComponent <GameController>(); if (!gameController.gamefinished) { //call Respawn() ballRespawn.Respawn(); } else { print("Game has finished, no respawn!"); ballRespawn.enabled = false; } } }