Particle Collision Trigger

I am trying to tie a collision to the emission of particles. I have created a “One Shot” particle emission, and the particle can play alone. The script I wrote below is my attempt at tying the collider to the particle emitter. Got any ideas?

	// Start "Confetti Particle System" when plane enters the trigger
function Update () {
	
	var jobesparticles = GameObject.Find("Confetti_Particle_System").GetComponent("Particle Renderer");
	jobesparticles.enabled=true;
}

function OnTriggerEnter (col : Collider) {
	// Emit particles for 3 seconds
	var jobesparticles = GameObject.Find("Confetti_Particle_System").GetComponent("Particle Renderer");
	Debug.Log("I hit my collider");
	jobesparticles.emit = true;
	//yield WaitForSeconds(2);
	// Then stop
	//Confetti_Particle_System.emit = false;
}

Thanks in advance!

You can actually add a component “World Particle Collider” under the particles components menu.

Well a sphere collider is attached to an object, once the player hits this object, the particle (location in the object) needs to animate. There is also a script attached to the collider that tracks points, so I wanted to attach a trigger for the particles to that same collider.

I am wanting to trigger a particle emitter to start when it is on the terrain and stop if it is off the terrain.
My terrain is tagged ‘ground’ my particle emitter is tagged ‘DustTrail’

My code is:

var DustTrail : Particle;

function OnTriggerEnter(ground:Collider){
DustTrail.enabled=true;
}

function OnTriggerExit(ground:Collider){
DustTrail.enabled=false;
}

Where am i going wrong? thankyou

You are incorrectly using the variable OnTriggerEnter and OnTriggerExit provides you.

Read this, you will understand.

Im sorry I still dont understand. I have been using colliders in my game to trigger time changes and level loads and have been using the same method and it works :s

This script works:

var particle : ParticleEmitter;
var particle2 : ParticleEmitter;

function OnTriggerEnter(ground:Collider){
particle.emit=true;
particle2.emit=true;
}

function OnTriggerExit(ground:Collider){
particle.emit=false;
particle2.emit=false;
}

Although it the game starts with it emitting which i dont want. ive tried turning off emit but then it doesnt emit at all. could you help please, ive nearly done it!

function OnTriggerEnter(hit:Collider){
	if (hit.gameObject.tag == "ground") {
		particle.emit=true;
		particle2.emit=true;
	}
}

function OnTriggerExit(hit:Collider){
	if (hit.gameObject.tag == "ground") {
		particle.emit=false;
		particle2.emit=false;
	}
}

Look carefully, you should understand.