Search Unity

2D physics callbacks propagation

Discussion in '2D' started by DNA-Studios, Nov 13, 2013.

  1. DNA-Studios

    DNA-Studios

    Joined:
    Oct 22, 2012
    Posts:
    5
    Hi,

    I started playing around with 2D physics engine and experimented a strange behaviour.

    In 3D physics mode, I often attach colliders on children of a game object. This game object has a rigidbody and a script attached to it which handles triggers or collisions called from the children.

    However, when I do such a thing with 2D physics (with 2D rigidbodies, 2D colliders, 2D callbacks methods, ...), the events are not triggered when a child collider hits something (the child does not have a rigibody). It happens only when the parent has a collider which collide against something.

    Did I miss something in the documentation ? Does anybody has a good explanation about it ?

    Thanks for help and the great job done by the team. New features are so cool ;)

    Cheers

    David
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    What you're probably seeing here is that the callback is occurring on the collider GameObject itself and not on the parent rigid-body.
     
  3. DNA-Studios

    DNA-Studios

    Joined:
    Oct 22, 2012
    Posts:
    5
    Yes and what is strange here is that with 3D physics you would expect the event to be propagated until it reaches the first parent with a rigidbody.
     
  4. jcman

    jcman

    Joined:
    Jan 12, 2014
    Posts:
    15
    This is an old thread, but I just came across this problem myself (or at least, difference between 2D and 3D behaviour). I often put my collision shape(s) and model on a sub-object so they can be scaled together, but I want my scripts on the parent object...

    Is this the way the system is supposed to behave, or is it a bug that will get fixed at some point?

    I guess I'll attach a collision-relay component or something to the child objects in the meantime.