help with my particle emitter script....

Could someone help me with syntax of this script. I am trying to have particles emit as my vehicle moves forward. I have this much but it is not correct. I think I am on right track, just need a little help…THANKS!!

function Update () {

if (Vector3.forward > 1){

	particleEmitter.emit = true;
}

else{

    	particleEmitter.emit = false;
}
}
if (Vector3.forward >= 1){

Or

if (Vector3.forward => 1){

Can’t remember.

Set it up so that whenever the player hits the button for moving forward you turn on the emitter, and whenever the button stops being pressed you turn off the emitter.

thought about that but need on AI cars also…thanks

will try it, thanks!

It’s the exact same thing with the AI, only you replace the check for the input with a check for the AI deciding to move forward. Also, if you don’t care which direction they’re moving, you can use this:

if (rigidbody.velocity.magnitude > .5) {

}

i like that…THANKS!!

Should I apply script to vehicle or particle itself…just making sure, need to get this working :slight_smile:

Always put the rigidbody check on the object with the rigidbody.

Thanks for the help, much appreciated!

MissingComponentException: There is no ‘ParticleEmitter’ attached to the “AICar2” game object, but a script is trying to access it.
You probably need to add a ParticleEmitter to the game object “AICar2”. Or your script needs to check if the component is attached before using it.
ParticleEmitVehicle.Update () (at Assets/ParticleEmitVehicle.js:5)

Getting this error. how do I tell it where particle emitter is at?? It is attached to vehicle but does not recognize it…

almost there:)

wheels are turning now, haha! I found my mistake, thanks!!!