//overwrites the parent class (AsteroidScript) explode method b/c we don't want to spawn more asteroids on death public override void Explode() { Instantiate(explosion, transform.position, Quaternion.identity); if (Random.Range(0, 100) <= spawn1upChance) { Instantiate(OneUp, transform.position, Quaternion.identity); } AsteroidCounter.decrememt(1); Destroy(gameObject); }
//Instantiantes the Explosion prefab at the asteroids current position //and decrements the amount of asteroids by 1, then destroys the GameObject public virtual void Explode() { Instantiate(SmallAsteroid, transform.position + (Random.onUnitSphere * -2), Quaternion.identity, transform.parent); Instantiate(SmallAsteroid, transform.position + (Random.onUnitSphere * 2), Quaternion.identity, transform.parent); Instantiate(explosion, transform.position, Quaternion.identity); //rb.AddExplosionForce (1000, transform.position, 100); if (Random.Range(0, 100) <= spawn1upChance) { Instantiate(OneUp, transform.position, Quaternion.identity); } //AsteroidCounter.increment (2); AsteroidCounter.decrememt(1); Destroy(gameObject); }