Search Unity

Can you pass a Collision2D to a parent object? (or to a group of objects?)

Discussion in 'Scripting' started by CleanCut, Jan 15, 2014.

  1. CleanCut

    CleanCut

    Joined:
    Aug 19, 2013
    Posts:
    10
    I would like to pass a collision to a group of objects, as if they were all rigidly attached to each other. Is there a way to do that in 2D physics?

    My first thought was to turn each object's collider into a trigger, and then use the info in the collision passed into OnTriggerEnter2D() to somehow pass the collision to a shared parent object which would move them all. The problem is that OnTriggerEnter2D is passed the "other" Collider2D instead of a Collision2D. But if I don't turn the colliders into triggers, then each object moves and reacts independently of the parent object.

    What I'm trying to accomplish is to have a collection of objects that act like one big object with one big collider interacting with the physics system, but I also want to kinematically move some of the components (in parent-local space) and add/destroy them.