- Home /
Does particle system's collision feature work with 2D colliders?
Hi,
Title says it all, I can't get it to work on 2D Box Colliders.
Thanks
Answer by HarshadK · Oct 15, 2014 at 01:48 PM
As long as I know particle system do not collide with 2D colliders.
Why it is not supported is because 2D objects do not even have a thickness on z axis and the particle system will work in 3D space with different z values for each particle, so they will flow behind or over the 2D object.
One way around will be to apply a 3D collider to your 2D object to register the collisions with particle system.
Thanks for the answer. So if we could attach a 2d collider to our particle, it would work, right?
This answer is so important. I want it to show as the top results when looking for info about 2D triggers and particle systems.
$$anonymous$$y use case, and how this finally freed me from agony by this answer: I have a particle system being used to create a bubble trail. I spawn bubbles as the character moves. The bubbles have a reversed gravity so they appear to float. They also have collisions, so they are nudged slightly as other objects swim through them. No problems so far.
What I needed to achieve was, the bubbles would be destroyed when they left the water (exited the collider for water). But! my water is comprised of multiple colliders of changing shape and position, (so that I can achieve complex waves and tides in a more dynamic manner.)
So I turned to the particle trigger module. I fed it all known water colliders in the scene, so that the bubbles would choose to destroy themselves at any point they found themselves not inside of at least one of the water colliders. (make two lists, one for outside particles, one for inside particles. decay all outside particles that are not on the inside particle list. Simple).
!!! The trigger module does not consider particles inside a 2D collider as inside that collider!!! Why? I have no idea. I thought it was my collision matrix, I thought it was starting queries from inside an object. I thought it was an offset of the z position value. All of these were wrong. Here is the solution. $$anonymous$$ake a 3D box, cause that is the only way they will be considered inside of the collider.
This answer is going to be brushed off as obvious, but I want to point out. when working in unity 2D, thinking of using a unity 3D component for a solution, feels like you're choosing to do something wrong.
Your answer
Follow this Question
Related Questions
Using joints brake the relationship parent-child 1 Answer
Get all particles within trigger collider? 1 Answer
Problem with moving an object and Uni2D Colliders 0 Answers
How does object shape influence its collision? 3 Answers
Collider with cinema 4D 2 Answers