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

Precisely controlling velocity of rigidbodies that are using joints

Discussion in 'Physics' started by Iron-Warrior, Jan 13, 2020.

  1. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    I am working on a VR project where the player has physical hands that directly interact with the world. Previously, the hands were a single rigidbody with several box colliders attached to roughly model out the shape of the hand (like a paddle). To make interactions more intuitive, the system was improved to instead be a static collider for the palm/wrist area, and then a series of rigidbodies for each digit, connected to the palm with ConfigurableJoint. An overview of the results can be seen here (with issues).

    To move the hand, its velocity/angular velocity is set every frame to interpolate towards the VR controller's position/orientation (interpolation is for gameplay purposes—it is not physically accurate). When no joints are connected to the hand, this works correctly with no issues. However, when joints are connected to the hand, the calculated per-frame velocity is now incorrect, as the extra mass from the joints is not taken into account. This causes the hand to sway around the goal, instead of smoothing moving to it.



    To resolve this, I set the mass scale of each joint to be very high. In Unity, this means that the parent joint is treated as much heavier than the child joints. This way, the digits' mass does barely affects. This resolves the swaying, and looks excellent in many conditions, but because the digits are treated as having very low mass, they become very unstable during collisions.



    The ideal solution would have none of the swaying, but all of the stability. In order to do this, the code that sets the velocity of the hand (and digits) must take into account the effect the objects connected to them will have. Is it a tractable problem to calculate this? I don't think this requires IK of any sort, but I'm not entirely sure where to begin, so I was hoping someone here would have some insight.

    Thanks for any help,

    Erik

    (x-posted from gamedev.net for visibility)