private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.TryGetComponent <Wall>(out Wall wall)) { CollisionToDestroy--; if (CollisionToDestroy <= 0) { BallDestroyer.DestroyBall(gameObject); } } }
IEnumerator CheckLifeTime() { yield return(new WaitForSeconds(LifeTime)); BallDestroyer.DestroyBall(gameObject); }