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

Question Particle systems and colliders with parent rigidbody.

Discussion in 'Physics' started by Paravil, Feb 6, 2022.

  1. Paravil

    Paravil

    Joined:
    Apr 13, 2020
    Posts:
    13
    The objects in my game are Rigidbody2D objects whose child objects have a collider. There are also guns in the game, for which I use particles as projectiles (this is relatively convenient, and I doubt the performance when using GameObjects as projectiles). For the normal operation of the guns, it is required to cause damage to the object that the particle collided with.
    And this is where the problem arises: OnParticleCollision only returns a GameObject, and instead of the one that the particle collided with, the parent object with the Rigidbody is returned. Adding a Rigidbody to child objects causes collision problems or even weirder behavior.
    Is there any way to determine which collider the particle has collided with, or do I still have to use GameObject projectiles?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    This isn't really physics, it's the particle system feature but that doesn't have it's own sub-forum so I'll add a tag to this post for you and hopefully a nice particle dev will come along.
     
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,240
  4. Paravil

    Paravil

    Joined:
    Apr 13, 2020
    Posts:
    13
    When GO returned by OnParticleCollision used as the argument, GetCollisionEvents returns null as the collider. When the object that the projectile should hit used as an argument, is also returned null.
     
    richardkettlewell likes this.
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,240
    Are you able to report this as a bug? I don't think its should ever be null.