Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Particle System collisions report wrong positions

Discussion in 'Physics' started by sergiusz308, Nov 18, 2020.

  1. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    199
    Unity 2020.1.13f1

    Hello, I got particle system with collisions enabled and script added with OnParticleCollision handler. In this method I spawn spheres at the points of intersection with collider.

    Code (CSharp):
    1. private void OnParticleCollision(GameObject other)
    2.     {
    3.         int c = ParticlePhysicsExtensions.GetCollisionEvents(this.ps, other, this.collisions);
    4.  
    5.         if (c > 0)
    6.         {
    7.             for (int i = 0; i < c; i++)
    8.             {
    9.                 ParticleCollisionEvent pe = this.collisions[i];
    10.                 if (this.DebugShape != null)
    11.                 {
    12.                     GameObject go = Instantiate(this.DebugShape, pe.intersection, Quaternion.identity);
    13.                     Destroy(go, 10f);
    14.                 }
    15.             }
    16.         }
    17.     }

    Problem is points of intersection are reported wrong (too high in my case) - what's wrong?

    Scene view shows some b-S***:

    red line - ground
    blue arrow- where collisions expected
    red arrow - where collisions are reported

    upload_2020-11-18_14-54-44.png

    Collision setup in the particle systems:

    upload_2020-11-18_14-46-8.png

    General setup:

    upload_2020-11-18_14-46-23.png

    Thanks,
    S.
     

    Attached Files:

  2. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    629
    So you want these particles to hit the floor? Floor doesn't move? Try disabling "Enable Dynamic Colliders"

    Otherwise check your layers again especially if the character is definately not on "spk_Environment".
    It's a 3D-Game, right? Hard to see from the screenshot. Otherwise set Mode to 2D.
     
  3. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    199
    @Hannibal_Leo thanks for suggestions - problem is that particle system for collisions is using sphere colliders and the way how it handles various particle types.

    So when particle rendering is set to stretched it will enlarge sphere collider to enclose stretched particle whole size which as a result gives you false positive collision reporting - you see stretched rectangle of the particle not hitting the object, but in reality it's big sphere is hitting it.

    Mystery remains is why interesection - point where collider hit the other object - is reported not where collider intersected with the other object (just like regular collisions work in uinty) but at some random position.

    To get what I want I had to add another particle system, with smaller particles, which then reported proper collisions.

    Hope it helps anyone.
     
  4. spikeles

    spikeles

    Joined:
    Jan 11, 2019
    Posts:
    9
    Set "Radius Scale" in your collision setup to zero

    Radius Scale Allows you to adjust the radius of the particle collision spheres so it more closely fits the visual edges of the particle graphic.

    When collisions are enabled, the size of a particle is sometimes a problem because its graphic can be clipped as it makes contact with a surface. This can result in a particle appearing to “sink” partway into a surface before stopping or bouncing. The Radius Scale property addresses this issue by defining an approximate circular radius for the particles, as a percentage of its actual size. This size information is used to prevent clipping and avoid the sinking-in effect.​