particle parameter scripting syntax

I’m trying to use a script to change some parameters on a particle effect, but not having much luck with the proper way to write it.

As a test, I’ve created a particle effect using GameObject>Create Other>Particle System and then parented it to an empty game object called Smoke. I then attached a script to the object “Smoke”, that contains the following:

function Update () {
	particleEmitter.minEmission = 200;
	particleEmitter.maxEmission = 200;
}

This of course doesn’t work, and I get various errors depending on the different things I try. I’m still pretty new to all this, so I haven’t had much luck trying to infer how to correctly do this from the scripting resource docs. All that document does is define what the various parameters do. It doesn’t give any examples of actual code.

How do I write this so that it sends the Emission instruction to the particle system attached to “Smoke”?

Ok, well in your case, the problem is that you parented the two game objects.
when you use the keyword particleEmitter, it looks for the ParticleEmitter component attached to the SAME game object the script is attached to.
Since the script is the only component attached to “Smoke”, it doesn’t find a particle emitter and returns null.
If you want to keep the hierarchy you created you can use:

public var myEmitter: ParticleEmitter;
function Start()
{
   myEmitter = GetComponentInChildren(ParticleEmitter);
   myEmitter.minEmission = 200;
   myEmitter.maxEmission = 200;

}

I suggest you read these:
Accessing other components
Accessing other game objects

Thanks. That did the trick. Thanks also for the links.

I have to admit this system of figuring out how to send a message to a particular object is still giving me a headache, but hopefully practice will fix that.