private void OnTriggerEnter(Collider other) { if (other.tag == "AsteroidCatch" || other.tag == "StellarBody") { if (!dead) { controller.SpawnAsteroid(GetComponent <AsteroidModel>()); dead = true; } Destroy(gameObject); } }
private void SpawnParentAsteroid(int index) { AsteroidController asteroid = AsteroidController.SpawnAsteroid(); Vector3 spawnLocation; do { spawnLocation = ScreenBounds.RandomLocationOnScreen(); } while ((spawnLocation - PlayerShipController.POSITION).magnitude < MIN_DISTANCE_AST_FROM_SHIP); asteroid.transform.position = spawnLocation; asteroid.transform.rotation = Random.rotation; asteroid.asteroidSize = currentLevel.initialAsteroidSize; asteroid.gameObject.name = "Asteroid_" + index.ToString("00"); }