Search Unity

Rigidbody component on both parent and child objects. To do or not to do?

Discussion in 'Physics' started by shakozzz, Apr 25, 2017.

  1. shakozzz

    shakozzz

    Joined:
    Mar 1, 2017
    Posts:
    60
    Hi all,
    About to start a VR project so was looking up the Oculus & Unity docs on best practices when I came across this sentence here about Rigidbodies:
    If I understood this correctly it means a child object which has a Rigidbody requires all parent as well as child objects to have Rigidbodies as well. I am, however, seeing a lot of opinions around the forums that pretty much warn against that very thing and advocate having only one Rigidbody in the parent-child chain. Check out this quote here:
    I couldn't find a definitive answer and I know for a fact that both versions work, since I've used both. However, is there a performance disadvantage to one or the other.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    If I've understood correctly, that sentence means that the non-static objects with colliders should belong to a rigidbody. It doesn't state that these colliders should also have a rigidbody. In any ways, this is not related specifically to VR or Oculus. The sentence just describes standard development practices in Unity.

    I think the sentence refers to an old issue causing a performance penalty when moving colliders not belonging to a rigidbody. However, this is no longer a problem since Unity 5 / PhysX 3.

    When working with Unity and Oculus I think it's important to understand what happens to your Camera objects. Any Camera not rendering to a texture will have its local Transform component governed by the head tracking. This means that you must put the camera as child object of another one in order to move or set the point of view, and move/rotate this parent object instead.
     
    Threeyes likes this.
  3. sgower

    sgower

    Joined:
    Mar 9, 2015
    Posts:
    316
    Generally you want to have a Rigidbody on the parent object and not on the children objects.
    Any colliders on the child objects will be handled by the parent Rigidbody. If you have Rigidbodies on the child objects, you'll run into problems if, for example, you set the parent and child to non-kinematic. I think the only time having child non-kinematic Rigidbodies is when the child is also connected to the parent via a Joint.