Not recognizing particle emitter

Well this one has got me confused. I’m trying to have a fire die out over time with this javascript:

#pragma strict
private var particlelife = 30.00f;

function Start () {
    particlelife = ParticleEmitter.maxEnergy / particlelife;
}

function Update () {
    ParticleEmitter.maxEnergy = ParticleEmitter.maxEnergy - (particlelife * Time.deltaTime);
}

After I attach the script to the emitter and hit play Unity tells me:
“An instance of type ‘UnityEngine.ParticleEmitter’ is required to access non static member ‘maxEnergy’.”

Shouldn’t it recognize the emitter when I attach it?
What am I doing wrong?

Thank you for any help anyone can lend me.

You need to use an actual instance of the ParticleEmitter; you can’t just call those functions on the name of the class itself. So like this:

private var particlelife = 30.00f;
private var myParticleEmitter : ParticleEmitter;
 

function Start () {

    myParticleEmitter = transform.GetComponent("ParticleEmitter");
    particlelife = myParticleEmitter.maxEnergy / particlelife;

}

 

function Update () {

    myParticleEmitter.maxEnergy = myParticleEmitter.maxEnergy - (particlelife * Time.deltaTime);

}

Hi

You have to acces to the particle emitter, you are calling like if ParticleEmitter was a static class try this, you need to get the component ParticleEmitter store it in a variable, then use your logic with this variable.

Something like that

That fixed it.
Thanks makeshiftwings, that was a lot of help.

I can see I’ve got a ways to go applying what I’ve been trying to learn before things will start to click.