- Home /
How to detect which exact particle element from a particle system hit a collider?
So I have a particle system, which emits some sprites and has collision. I wanna know exactly which element of that array of particles in the particle system was hit, because when the particle system hits something, I wanna delete ALL the particles forward to the particle element in the array that didn't hit a collider. Its just that when that particle system hits something, I don't want the particles that where ahead before the collision happen to stay alive, cause it looks weird to see just random survivor particles roaming around, lol.
Thank you... Here is my code so far...
public class ParticleScript : MonoBehaviour { public ParticleSystem theParticleSystem; public ParticleSystem.Particle[] aliveParticles; private int particleLenght;
// Use this for initialization
void Start () {
theParticleSystem = transform.GetComponent<ParticleSystem>();
aliveParticles = new ParticleSystem.Particle[theParticleSystem.main.maxParticles];
// aliveParticles = GetParticles(theParticle);
}
// Update is called once per frame
void Update () {
particleLenght = theParticleSystem.GetParticles(aliveParticles);
print(particleLenght);
}
private void OnParticleCollision(GameObject other)
{
}
}
Your answer
Follow this Question
Related Questions
How to keep particles moving past an obstacle after they have collided with it? 3 Answers
Unity 2D Particle System's collider doesn't trigger other colliders for scripts. 0 Answers
How can I restrict Z axis in 2D particle collision? 0 Answers
Programmatically Enable/Disable Shurikan Particle Collision Module 3 Answers
How to make OnParticleCollision affect multiple GameObject 1 Answer