- Home /
How can I activate a Particle system using a box collider as a trigger
Ive been developing a small mini game where you fly around as a bird pooping on people. I have a prefab called poop which drops downward on the y axis it has a sphere collider attached to it and a rigidbody. I have made a particle system the child of a character who walks around the map the particle system has a box collider which i set as trigger. Now i cant figure out how to make the particle system play when the poop prefab hits it,............ Can anyone help me pls
Answer by Jessespike · Oct 07, 2015 at 08:11 PM
Have you tried OnTriggerEnter()?
void OnTriggerEnter(Collider other) {
GetComponentInChildren<ParticleSystem>().Play();
}
thank you worked like a charm now theres a nice big poop splat that comes off the character :)
Answer by ItsaMeTuni · Oct 07, 2015 at 08:38 PM
Try this out:
void OnTriggerEnter(Collider other) {
if (other.tag == "character") {
GetComponentInChildren<ParticleSystem> ().Play ();
}
}
set your character tag to "character". this code is attached to the character.
This also worked either method is acceptable and in this case it would be wise to tag the character anyhow so thank you sir
Your answer
Follow this Question
Related Questions
Hello, How would one make a particlesystem activate triggers? (hopefully I worded that right) 0 Answers
How can I get multiple objects with triggers, and standard collisions to work together? 2 Answers
Particle colliders being left behind particles? 0 Answers
Can I make a collider ignore only one other collider? 0 Answers
changing gravity OnTriggerEnter 1 Answer