void OnDestroy() { if (!isQuitting && !GameManagerSys.isInMainMenu && !GameManagerSys.isSwitchingLevel) { Vector2 currentPos = transform.position; foreach (GameObject asteroid in childsAsteroids) { Vector2 position = new Vector2( currentPos.x + Random.Range(-circleColliderRadius, circleColliderRadius), currentPos.y + Random.Range(-circleColliderRadius, circleColliderRadius) ); GameObject tmp = Instantiate(asteroid, position, Quaternion.identity); tmp.GetComponent <Rigidbody2D>().velocity = new Vector2(speed.x + Random.Range(-0.5f, 0.5f), speed.y + Random.Range(-0.5f, 0.5f)); tmp.GetComponent <Asteroid>().AsteroidSpawner = asteroidSpawner; } GameManagerSys.IncrementScore(); if (childsAsteroids.Count != 0) { asteroidSpawner.OnBigAsteroidDestroyed(); } } }