Search Unity

Rigidbodies and colliders of child moving parts

Discussion in 'Physics' started by Desprez, Dec 17, 2015.

  1. Desprez

    Desprez

    Joined:
    Aug 31, 2012
    Posts:
    305
    I'm a little unsure of the best way to set up colliers on complex object hierarchies when the root object has a rigidbody.

    I understand that if a collier will be moved, it should have a rigidbody, otherwise Unity will interpret the collider to be static, and moving a static object is bad.

    For complex object hiearchies, Unity will collect all the child/sub-child colliders and make them a compound collider for the parent rigidbody. (Therefore, the child colliders don't each need their own rigidbody since the parent rigidbody satisfies this requirement when part of a compound collider.)

    So far so good.

    But now what if one of those child colliders is an object that will be moved via script (like a gun turret or some mechanical part). Because the part is moving (in relation to the parent), it should have a rigidbody (kinematic).

    This seems consistent, as I imagine that moving a part of a compound collider would force the recalculation of the whole collider, and this sounds bad for performance.

    I can give it a rigidbody, and this in turn will separate it from the parent compound collider (yes?) while creating its own compound colliders of its child colliders.

    But if I give it a kinematic rigidbody, then if any part of it ever intersects with a sibling/parent collider, then everything goes crazy.

    What's the proper way to handle this?
     
  2. Desprez

    Desprez

    Joined:
    Aug 31, 2012
    Posts:
    305
    Ok. I'll try to rephrase:
    If a child object with a collider is going to move via script (in relation to its parent) it should have a kinematic rigidbody. Yes?

    If it doesn't, moving it will cause performance issues.
    If it does, collider collision will cause problems with the root non-kinematic rigidbody.

    If the former is true, I'll have to go through some effort to make sure that rigidbody doesn't intefere with root rigidbody.
    Does this sound like the right approach?
     
  3. pauloaguiar

    pauloaguiar

    Joined:
    May 13, 2009
    Posts:
    700
    I´m confuse. You mean after explode for example you need that torrent split and detach from parent in body parts?
     
  4. Desprez

    Desprez

    Joined:
    Aug 31, 2012
    Posts:
    305
    Now I'M confused. What?