Emit Particle when the parent gets collision

I’m making an evasion game where you have to evade objects with a ball in a random generated world.
When that ball hits an object, that object has to emit a particle.
But when the ball hits the object , that object doesnt emit a thing.
And when the prefab of that object spawns again the particle is constantly emitting.

this is the code i used to emit the particle
the private var goan gets a boolean from the object (true = collision on object)

private var hitParticles : ParticleEmitter;

private var  goan = FlasherScript.ParticleEmit;

function Start () { 
    hitParticles = GetComponentInChildren(ParticleEmitter);   

    if (hitParticles) {
        hitParticles.emit = false;
    }
}

function Update () {    
	if(goan == true) {
        Emitten();
	}
}

function Emitten() {
    hitParticles.emit = true;
    yield WaitForSeconds(3);        
	hitParticles.emit = false;
}

You are only initializing goan (i.e. once). Try something more like this:

private var hitParticles : ParticleEmitter;

private var goan = false;

function Start () { 
    hitParticles = GetComponentInChildren(ParticleEmitter);   

    if (hitParticles) {
        hitParticles.emit = false;
    }
}

function Update () {
    if (FlasherScript.ParticleEmit && !goan) {
        goan = true;
        Emitten();
    }
}

function Emitten() {
    hitParticles.emit = true;
    yield WaitForSeconds(3);        
    hitParticles.emit = false;
    goan = false;
}

You could simplify it a lot further too (the goan variable isn’t really needed at all), but the above hopefully highlights the mistake.

Thx , now the partical emits when it collides , strange thing is they don’t stop emitting.

But you were a great help, Big Thanks! :wink: