Search Unity

Move a Rigidbody in a fixed joint without affecting the other

Discussion in 'Physics' started by mespino, Feb 17, 2017.

  1. mespino

    mespino

    Joined:
    Nov 26, 2015
    Posts:
    15
    Hello,

    I think this is a very common question but I do not find any answer.

    I have a mass attached to another by a fixed joint.
    The mass simulates a load cargo attached to a vehicle.

    By design, It has to be possible to move the cargo. I have been trying to move it modifying the anchors, but it makes weird behaviours.

    I have seen target position, but I not able to make it works. And I have tried to do it with JointDriveMode, but it says:
    Code (CSharp):
    1.     //
    2.     // Summary:
    3.     //     ///
    4.     //     The ConfigurableJoint attempts to attain position / velocity targets based on
    5.     //     this flag.
    6.     //     ///
    7.     [Flags]
    8.     [Obsolete("JointDriveMode is no longer supported")]
    So, if JointDriveMode is obsolete, what it is the accepted/right way to move a rigibbody attached to another by a joint?

    Regards
     
  2. mespino

    mespino

    Joined:
    Nov 26, 2015
    Posts:
    15
    I answer my own question for other with the same problem.

    Moving the anchors works fine, but you have to move the transform before:
    Code (CSharp):
    1.         public void SetLocalPosition(Vector3 localPosition)
    2.         {
    3.             transform.localPosition = localPosition; //DO THIS
    4.             joint.connectedAnchor = localPosition;
    5.        }
     
    imaginationrabbit likes this.