How do i destroy a character and have a particle effect after?

I have a enemy character that comes at me and once i kill him he falls and disappears. I created a particle effect that suppose to appear right after he disappears,as if he turns into dust. how would i go about doing this? I tried to create an empty game object and attach the particle system to it which didn't work. Then i tried to attach the particle system to enemy character and i still can't get it to work. Please Help!

  • make a gameobject
  • add particle effect to it with auto-destruct on
  • make a prefab of this gameobject
  • optionally test if particle object does it's job (create new scene, place gameobject in view, press start, you should see the effect and object should clean up)
  • modify your script to instantiate the effect:

var dieEffectsPrefab : Transform;

function Die() {
    Instantiate(dieEffectsPrefab, transform.position, transform.rotation);

To respond to one of the comments, the Auto-destruct should destroy the gameobject the particle is a component of so it's not really necessary to add the delayed Destroy. If you do add the delayed Destroy, you should destroy the gameObject, not the transform you get back from the Instantiate. So code would become:

var dieEffectsPrefab : Transform;
var timeOut : float = 3.0;

function Die() {
    var instance = Instantiate(dieEffectsPrefab, transform.position, transform.rotation);
    Destroy(instance.gameObject, timeOut);

But once again, when you check the auto-destruct in the particle animator, you don't need this extra code.

This works for me, using ParticleSystem. Code is attached to the object we are destroying:

public ParticleSystem DestructionEffect; //assign prefab in editor or elsewhere
                                         //in code
void Explode()
       //Instantiate our one-off particle system
       ParticleSystem explosionEffect = Instantiate(DestructionEffect) 
                                        as ParticleSystem;
       explosionEffect.transform.position = transform.position;

       //play it
       explosionEffect.loop = false;

       //destroy the particle system when its duration is up, right
       //it would play a second time.
       Destroy(explosionEffect.gameObject, explosionEffect.duration);

       //destroy our game object

you ca’nt detroy other object in present script of other object , you must add a script into particle effect
example:void start()

3 : the time detroy;