Controlling a GameObject Instantiated ParticleSystem Prefab?

Hi,

When the player instantiates a particlePrefab, particles emit at the players position. What I need to do is for when the player moves, I need the particles to move with the player, in the direction the player is going, and also to gradually destroy several of the particles (not all of them at once).

Essentially, the player runs up to a trigger, player instantiates particles, player moves, particles destroy immediately (not what I want). I need to gradually destroy particles in the direction the player moves in...for now, I am working on gradually destroy particles (fading them out) while holder[4].a is > 0.

`//In seperate script file
public static ParticleAnimator myEmissions
;

myEmissions = (ParticleAnimator) Instantiate(particlePrefab, transform.position, Quaternion.identity);
//End seperate script file

public static ParticleAnimator emitters
;
//Call our coroutine to gradually destroy particles

public static IEnumerator ResetParticles()
{

resetting = true;
holder = new Color[5];
holder[4].a = 1;

while (holder[4].a > 0) 
{
    foreach (ParticleAnimator m_emitter in emitters) 
    {
        if (m_emitter) 
        {                   
            holder = m_emitter.colorAnimation;
            holder[4].a -= .005f;
            m_emitter.colorAnimation = holder;
        }
    }
}
foreach (ParticleAnimator m_emitter in emitters) 
{
    if (m_emitter) 
    {
        m_emitter.particleEmitter.emit = false;
        m_emitter.particleEmitter.ClearParticles();
    }
}
    resetting = false;
    sent = false;

yield return 0;

}
`

What the above does, without a PreFab instantiation is destroy's particles gradually. I need to be able to use my instantiated GameObject variable because it has the instantiated particle prefab.

In ParticleEmitter check One Shot.

Drag particle system onto player GameObject.