Search Unity

Particle collision against moving Collider+Rigidbody

Discussion in 'Physics' started by EmmaEwert, Apr 25, 2015.

  1. EmmaEwert

    EmmaEwert

    Joined:
    Mar 13, 2014
    Posts:
    30
    I am having issues generating collisions between Mesh particles and a moving BoxCollider+Rigidbody.

    None of the defined collision effects happen, despite having ticked Send Collision Messages in the Particle System inspector and set it to collide with World.

    I have attached the method below both to a script on the Particle System GameObject and the BoxCollider+Rigidbody (Windscreen) GameObject. It is never called from either.
    Code (CSharp):
    1. void OnParticleCollision(GameObject other) {
    2.   Debug.Log(other.name);
    3. }
    My immediate assumption is that particles only collide with static colliders. Is this the case?

    If not, what might I be doing wrong for no collision effects to happen?

    The particle system is fairly spread out at a radius of 256 units, but even with a radius of 16 units, not a single message is received.

    I have verified that the particles actually do go through the collider by visualising it with a translucent cube.

    If particles only collide with static colliders, would it be better to tick the wind screen as static (despite it moving every frame), or to drop the particle system entirely and use full-fledged game objects for the particles?

    The effect I want to achieve is dust particles colliding with a spaceship windscreen, triggering several events - sub-emission of smaller particles, particle velocity change, spatial impact sound playback and windscreen scratch decal application, among other things.

    Considering my complex requirements, I would fully understand if these things can not be simulated through a particle system - or even if they can, why it would be less performant or desirable to do so regardless.

    Either way, I would like concrete information on what I am doing wrong and/or what limitations exist for particle collisions with moving world colliders.

    Note: I could also move the world and have the spaceship be static and stationary, but that would require a massive amount of individual existing particle updates on every velocity change for the effect to be believable. I don't think hundreds (or possibly thousands) of particle updates every frame while accelerating is more performant than other solutions, anyway.
     
  2. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    I made some particle systems that collide with rigidbodies so it works in general.

    To figure this one out you probably may want to start small - with just one particle. Because one particle should work for sure. If it still isn't working still - then something is wrong in setting somewhere (maybe ParticleSystem collision settings, wrong layer assigned to collider, too low collision quality)
     
    Last edited: Apr 26, 2015
  3. EmmaEwert

    EmmaEwert

    Joined:
    Mar 13, 2014
    Posts:
    30
    Thanks for the advice, I will try toying around with very basic setups and figure out where the issue is.

    That being said, I have had to roll my own particle system due to the sheer number of particles I desire - several magnitudes more than the 65535-particle limit for Particle Systems.

    Nevertheless, I will want to look into the built-in collision for simpler cases in the future.