Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Vibrations when attaching rigidbodies using FixedJoint

Discussion in 'Physics' started by artaka, Apr 24, 2018.

  1. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    I have a animated character with a kinematic rigidbody parented to its back (let's call this BodyA). When I attach another rigidbody (BodyB) to BodyA using FixedJoint, BodyB vibrates.

    When parenting BodyB to BodyB instead, there are no vibrations at all. However I don't want to parent it because I want to easily attach and detach when needed and I only need to apply the position of BodyA to BodyB but preserve BodyB's rotation as is.

    Any ideas what I can do to prevent it from vibrating?
     
  2. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    I finally figured it out. For those of you who may run into the same issue, I ended up ditching FixedJoint.

    What seems to happen is physics evaluates before the animation does and at different time intervals. Therefore all the rigidbodies on the animating skeleton were out of sync with the animation. Setting the Animator Update Mode to Animate Physics broke things even more. So my solution was to attach the two rigidbodies simply using its transform.position in LateUpdate. Such as:
    Code (CSharp):
    1. void LateUpdate()
    2. {
    3.     BodyB.transform.position = BodyA.transform.position;
    4. }
     
  3. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    but it defeats the purpose/advantages of joints.
    I hope physX 3.4 has these things worked out.
     
  4. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    Yeah, I assumed that setting Animator Update Mode to Animate Physics would sync the Physics and Animation together. But I got really strange and unexpected results.