Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Accurate Physics in VR

Discussion in 'Physics' started by ColtonKadlecik_VitruviusVR, Mar 17, 2020.

  1. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Hey All,
    Just have a couple quick questions that I am hoping someone more knowledgeable in Unity physics can answer. We are currently working on a new VR game and have a physics based body/avatar that has configurable joints between each collider/bone which works well. I have just started interacting with items and it seems I have 2 options for attaching items to the hand. I can either create another joint between the hand and item, or I can parent the item onto the hand. Which would be more physically believable? I am leaning towards the parenting route as the hand needs to stay posed around the item and a joint is never perfect. If I do go the parenting route, can I parent the item with its existing rigidbody on it (I have read conflicting opinions about this)? Will the child properties (mass/center of mass etc.) be taken into account when simulating or would it be better to add those properties to the parent RB?
    Thanks,
    Colton
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,497
    Have in mind that parenting rigidbodies has no effect in them. They will behave as independent bodies unless they're attached with a joint.

    In order to use parenting:
    • Mark the object as kinematic.
    • From scripting, use Rigidbody.MovePosition and Rigidbody.MoveRotation from FixedUpdate to make the object follow the position and rotation of its parent.
    • Optionally, apply the rigidbody properties (mass, center of mass) to the parent body.
    Note that this doesn't actually require the objects to be parented. Dropping the object just requires clearing the kinematic flag.
     
  3. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Thanks for the reply @Edy. Just another question (somewhat related), if I have an item with a hinge joint and I want the total mass of the item to be 2, would I put 1 mass on the first object and 1 mass of the hinged object? Or does the mass of the hinged part not affect anything?
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,497
    If none of the rigidbodies are kinematic then use the mass intuitively. The mass of 2 bodies liked with a joint is the sum of their masses.