Particle emit on collision with a gameObject

When my character hits a gameObject “Switch” I use .SendMessage to tell a “Reactor” script to emit the particles. It doesn’t seem to effect the Particle System to start the emitters… keeps saying ambiguous reference.

Reactor Script:

ParticleSystem particle = (ParticleSystem)gameObject.GetComponent("ParticleSystem");

    function React ()
    {
    particle.enableEmission = true;
    }

Switch Script:

	

function OnTriggerEnter(other:Collider)
    {
    	
    	
    	if(other.gameObject.tag == "Switch")
    	{
    	gameObject.Find("WinPartical").SendMessage("React");
    	Debug.Log("Activated!");
    	}
     
    }

My game is basically collect coins and power ups, when you reach the end you hit the “Switch” and it activate the particals on the objects to green to signify you winning. right now i hit the “Switch” and it gives me the Debug.log(“Activated!”); and nothing else happens. Please help im stuck.

Attach a Particle System to your trigger object. Then try this code.

var coins : int;


function OnTriggerEnter (other : Collider) 
{
    if(coins == 10)
    particleSystem.Play();
    
}

You can then increment the coins from another script when you grab them. That’s the simplest way I can think of doing it.