particle emit on call

i want my gun to emit smoke every time i press the fire button then stop when i release it.
i was thinking something like this would work…

function if(Input.GetButtonDown(“fire1”)){
particle.emit=true;
particle2.emit=true;
}
}

else if (Input.GetButtonUp(“fire1”)){
particle.emit=false;
particle2.emit=false;
}
}

You need to spend some more time in programming tutorials :slight_smile:

With your syntax fixed, your way should work.

if ( Input.GetButtonDown("fire1") ) {
  particle.emit = true;
  particle2.emit = true;
} else if ( Input.GetButtonUp("fire1") ) {
  particle.emit = false;
  particle2.emit = false;
}

uhh thanks for the reply, i just tried this but, iam new with scripting and call me stupid but i get an error, unknown identifier particle.

so i changed it to this, but still didnt work

var Particle : ParticleEmitter;

if ( Input.GetButtonDown(“Fire1”) ) {
Particle.emit = true;
} else if ( Input.GetButtonUp(“Fire1”) ) {
Particle.emit = false;
}

bump

var Particle : ParticleEmitter;

if ( Input.GetButtonDown(“Fire1”) ) {
Particle.emit = true;
} else if ( Input.GetButtonUp(“Fire1”) ) {
Particle.emit = false;
}

 is your friend
reference variables need to be initialized

[code]var particleEmitter : ParticleEmitter;

[B]function Start() {
 particleEmitter = GetComponentInChildren( ParticleEmitter );
}
[/B]
function Update() {
 if ( Input.GetButtonDown("Fire1") ) {
  particleEmitter.emit = true;
 } else if ( Input.GetButtonUp("Fire1") ) {
  particleEmitter.emit = false;
 }
}

but
particleEmitter.emit
Enabled then disabled the particles like displaying them then hide them …

i suggest to use

particleEmitter.minEmission =particleEmitter.maxEmission = 0; // to kill the particles

too have some fading in on/off the emitter, like inflame flames :wink:

goodluck.