- Home /
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.
Answer by VictoryX · Mar 06, 2013 at 09:34 PM
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.
Your answer
Follow this Question
Related Questions
,Particle System - Throwing Effect 1 Answer
How to get particles to work with all versions of Unity 5? 0 Answers
How to detect collisions between a particle system and a gameobject 1 Answer
3D Particles collision don't work 0 Answers
How to make physics collision dotted simulation like bubble shooter ? 2 Answers