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?
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.