- Home /
How can i make a Child ParticleSystem Emit or not Emit on certain events
Certain events such as OnCollision Enter Enter, and or OnCollision Exit.
Answer by yashpal · Oct 25, 2014 at 06:14 AM
Hello Xeong-Hu You can use this code. inside OnCollision Enter Enter, and or OnCollision Exit.
transform.FindChild ("ChildObjectName").gameObject.particleSystem.Play ();
transform.FindChild ("ChildObjectName").gameObject.particleSystem.Stop ();
Hello there. thank you for replying. I tried out your code and it worked.
But When ever I try to emit my particle on Collision it doesn't Emit.
I printed out a $$anonymous$$SG in the script to see if it's colliding and it turns out it is. $$anonymous$$y Particle doesn't want to emit for some reason.
Here's what my Code looks like.
function Start () {transform.FindChild ("Ripples Prefab").gameObject.active = false;
}
function OnCollisionEnter(collision: Collision) {
if (collision.gameObject.tag == "Water"){
print("It's Colliding");
transform.FindChild ("Ripple Prefab").gameObject.particleSystem.Play ();
transform.FindChild ("Ripples Prefab").gameObject.active = true;
}
}
function OnCollisionStay(collision: Collision) {
if (collision.gameObject.tag == "Water"){
print("It's Colliding");
transform.FindChild ("Ripple Prefab").gameObject.particleSystem.Play ();
transform.FindChild ("Ripples Prefab").gameObject.active = true;
}
}
Alright, Nvm. I just took out the .Play functions and left them with the Active Function.
Thanks for the help though!
Your answer
![](https://koobas.hobune.stream/wayback/20220613165908im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom 2D Particle System 0 Answers
Drag line between game objects 0 Answers
Unity BUG crash when modify ParticleSystem MinMaxCurve 0 Answers
Runtime AnimationCurve+ParticleSystem.startSpeed 0 Answers
Unity 5.4 Particules systems crashes with Window 10 updates 0 Answers