- Home /
Particles colliding/triggering Particles. Is it possible?
Is it possible, in any way in 5.6 or 2017.1, to detect ParticleSystem over ParticleSystem collision or triggering?
Answer by tanoshimi · May 28, 2017 at 07:42 PM
Well, you could call GetParticles() on each system to get two arrays of particles, then do a nested loop to compare whether the distance between each pair of particles is less than the sum of their radii (in which case, they're colliding).
Expect it to be slow if you've got a lot of particles though (which is why this method probably doesn't exist - the whole point of particle systems is to render a large number of simple particles without having the overhead of components like colliders).
Well that's actually a good workaround I didn't think of. It seems logical although my goal was improving performance by calling only 2 batches (2 particles systems) ins$$anonymous$$d of sprite bullets destroying colliders AND enemy bullets (thus the need of collision between 2 Particle systems) in a TOTAL bullet havoc top down shooter. Crazy. I'll try your solution and a sprite solutions (which I'm working right now) and see which of the two versions is the most performance efficient. Thank you! I won't give you accept, but I'll give a thumbs up for the good recommendation.
Answer by ShadyProductions · May 28, 2017 at 04:39 PM
Take a look at this: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleCollision.html
I know how to do ParticleSystem over Collider 2D or 3D. What I want to know is how to do detections over individual particles of one ParticleSystem and individual particles over another ParticleSystem. I don't know if this is even possible in the new versions of Unity. For the older ones I'm sure. Thus the question.