Trying to make a flamethrower, can't control fire?

So I pulled “Flame” out of the Standard Assets and stuck it on my Car object.

Then I dropped this script into the assets folder:

var emitter : ParticleEmitter = GetComponentsInChildren(ParticleEmitter);

if (Input.GetButton("Fire1")){ emitter.emit=true;





And promptly got this error:

Assets/fire.js(1,56):BCE0022: Cannot convert ‘Unity Engine.Component’ to ‘UnityEngine.ParticleEmitter’.

I’m trying to make it so I can control the fire by clicking. What am I doing wrong?

You’re using GetComponentsInChildren, which returns an array of all instances of that type of component. You can’t assign an array to a single ParticleEmitter variable. Try just using GetComponent, but make sure the script is also on the Car object.