using UnityEngine; // Put this on things that will explode when they enter the collision trigger // an Explosion script public class Explodable : MonoBehaviour { // Light is optional (only if you want the exploded object to create light) public Light explodeLight; public ParticleSystem explodeParticle; public float explosionLengthTime; public void Explode() { if (explodeLight != null) { explodeLight.gameObject.SetActive(true); explodeLight.transform.parent = null; Destroy(explodeLight.gameObject, explosionLengthTime); } if (explodeParticle != null) { explodeParticle.gameObject.SetActive(true); explodeParticle.transform.parent = null; //explodeParticle.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); explodeParticle.Play(); Destroy(explodeParticle.gameObject, explosionLengthTime); } Destroy(gameObject); } }