- Home /
 
 
               Question by 
               systmfdwn147 · Mar 12, 2013 at 12:28 AM · 
                particlesdestroyexplosion  
              
 
              How to get rid of (cloned) particles after an explosion
When I shoot the object that's being exploded I get prefab_explosion (cloned) where the object was destroyed. I've googled and googled and tried what I've already learned and I can't seem to get rid of these objects
 var bulletSpeed : float = 15.0;     //speed of the bullet
 var heightLimit : float = 10.0;     //range the bullet can travel
 var explosion   : Transform;
 
 
 function Update () 
 {
     transform.Translate(0,bulletSpeed * Time.deltaTime,0);
     
     if(transform.position.y >= heightLimit){
         Destroy (gameObject);
     }
 }
 
 function OnTriggerEnter (other : Collider)
 {
     //check for the astroid
     if(other.gameObject.tag == "astroid"){
         Destroy(gameObject);
         other.transform.position.y = 7;
         other.transform.position.x = Random.Range (-5.7, 5.7);
     
     //create the explostion on impact
     Instantiate (explosion, transform.position, transform.rotation);
     
     
 }
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Chronos-L · Mar 12, 2013 at 12:46 AM
Attach this script to your particle system.
 //KillParticle.js
 
 function Update() {  
    if(!particleSystem.IsAlive()) {
       Destroy( gameObject );
    }
 }
 
              Answer by Auggie · Mar 12, 2013 at 01:19 AM
make another script that destroys an object
something like:
function Start (){
 Invoke("Kill", 3); // this will call on Kill() in 3 seconds
 
               }
function Kill (){
 Destroy(gameObject); //this will destroy the object it is attached to
 
               }
and attach it to the explosion prefab.
Your answer