void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Ball") { Destroy(col.gameObject); GameObject paddle = GameObject.Find("Paddle"); PaddleController paddleController = paddle.GetComponent <PaddleController> (); paddleController.SpawnBall(); GameManager.Instance.Life -= 1; } }
private void OnTriggerEnter2D(Collider2D other) { bool isBall = other.CompareTag("Ball"); bool isPowerup = other.CompareTag("PowerUp"); if (isBall || isPowerup) { PaddleController.ballList.Remove(other.gameObject); Destroy(other.gameObject); if (isBall) { paddle.SpawnBall(); } } }