- Home /
Wrong particle system playing with OnParticleCollision call - how do I call different particle systems using a single particle collision JS?
Hi
I'll start by explaining exactly how I have things set up - just in case it helps (old QA habits).
I have a scene where I control a cylinder with the third person controller, which has a particle system child playing on it. So when I move around, the particle system comes with me. It is essentially a flame which emits straight up on the y axis. I have a script on this particle system which detects particle collisions with a tagged game object (a cube). When that collision is detected (which it is, that is working ok), I trigger a particle system on the cube to begin playing (to emulate an effect where my flame has caused the cube to set on fire). I trigger the particle system on the cube by basically calling a function to play it from another JS.
When I then duplicate the cube - and link the new particle system to it in the inspector, I expect that it should then call that particle system I have linked instead of the original one on the original cube.
The behavior I am seeing though is that when I burn the new box, it triggers the particle system for the original box instead. Box one continues to burn as expected if collided with, but box 2 does not - instead triggering the particle system on box 1. The only thing that does fire as expected is the cylinders particle collisions with the new box.
I must be missing something so obvious, im a bit of a n00b, but im struggling with the logic. If I drag and drop the new cube's particle system into the inspector, surely thats the one which should be linked and not the first one?! Please help im going mad.
Heres the code on the player's particle system:
var boxFire : boxFire;
function OnParticleCollision (collision : GameObject) {
if (collision.transform.tag == "BurnBox") {
Debug.Log ("Particle collisions detected for box!");
boxFire.startFire();
}
}
Here is the code on the cube:
var boxParticleSys : ParticleSystem;
function startFire(){
Debug.Log ("Starting the fire for box!");
boxParticleSys.Play();
}
Thanks for taking a look!
Your answer
Follow this Question
Related Questions
Whirlwind spell collision detection 1 Answer
Detecting collision between particle and player. 2 Answers
How to simply enable an objects particle system emission when that object collides with another? 1 Answer
OnParticleCollision not responding! 0 Answers
Let Particles sit on Collider without triggering callback - OnParticleCollisionEnter? . 1 Answer