public void CheckForDeath() { if (Input.GetKeyDown(KeyCode.Backspace) || health <= 0) { player.SetActive(false); if (gameOver == null) { Debug.Log("Can't find gameOver"); } gameOver.SetActive(true); spawnManager.CancelInvoke(); spawner.SetActive(false); } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Ground") { Grounded = true; } if (collision.gameObject.CompareTag("Obstacle")) { animator.SetTrigger("Dead"); // animator.enabled=false; Destroy(collision.gameObject); spawnObj.CancelInvoke("Spawn"); // canvas.gameObject.SetActive(true); } }
void gameOver() { gameOverText.gameObject.SetActive(true); Debug.Log("game over"); state = gameState.end; spawner.CancelInvoke(); for (int i = 0; i < spawner.balls.Count; i++) { Debug.Log("removing " + i); Debug.Log("count " + spawner.balls.Count); Destroy(spawner.balls[i]); } for (int i = 0; i < spawner.balls.Count; i++) { spawner.balls.Remove(spawner.balls[i]); } }