getting script to work

hey im trying to get my particle to play when i click on the object. This is my script right now but it isnt working because it’s probly way off.

function Start () {

ParticleEmitter.emit = false;

}

function Update (){

if (Input.OnMouseDown())

particleEmitter.emit = true;

}

Thanks for help

Only a couple of fixes.

Look at the differences and you will see where they are.

function Start () {
	particleEmitter.emit = false;
}
function Update (){
	if (Input.GetMouseButton(0))
		particleEmitter.emit = true;
}

Actually, I think he’s looking for slightly different functionality (when clicking on the object, not just clicking)

function Start () {
    particleEmitter.emit = false;
}
function OnMouseDown () {
    particleEmitter.emit = true;
}

or use Input.GetMouseButtonDown(0) :wink:

Another would be to toggle the emitter:

particleEmitter.emit = !particleEmitter.emit;

Hey the problem im having now is the particle is going when i start playing. And yes, i would like the particle to play when i click on the object:). I belive that that goes in the function start which is what i have.

function Start () {

particleEmitter.emit = false;

}

Yeah so if you guys could tell me what i got going wrong id be greatfull :slight_smile:
thanks again for the help

have you attached the script to the correct GameObject? The code posted works.

Yeah I got it attached to a cube. I dont know if i got to uncheck something in the particle because it is a new particle.

I may have figured it out. Where am i supposed to add this script? I have it on the cube at the moment.
And i saw on the particle “play on awake” should that be off? because it stops the particle from going when i start play.

This script would need to be on the particle effect itself.

The ParticleEmmiter class has no static emit property. Instances of it do though. :wink:

Also, always use {…} braces for if clauses.

Yay! I got it to work:))) turns out i had to creat a brand new particle system instead of adding it in compents haha
Really happy now! Thank you all for helping me!!:smile: