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

Distance joint2D not maintaining distance?

Discussion in '2D' started by ktest112233, Mar 4, 2019.

  1. ktest112233

    ktest112233

    Joined:
    Jan 7, 2019
    Posts:
    37
    Hi, I am using distance joint 2D to connect 2 rigidbodies.

    When i move body from point A to B very quickly, the body do not maintain the mentioned distance, it takes a few frame for adjustment. The maximumDistanceOnly is checked but still I am getting this issue.

    It's acting more like spring joint and not distance joint

    Any solutions to this? Thank you
     
    Last edited: Mar 4, 2019
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,314
    Are you "moving" the body by setting the Transform directly? If so, that isn't moving, it's teleporting the object from one position to another instantly. This means the joint then has to try to get it back into a correct position for the constraint.

    Rigidbodies should be moved by the physics system only. Only use forces, set the velocity or using MovePosition and MoveRotation.

    If you're not setting the Transform directly then I'm not sure what's going on. Perhaps you could share your movement code.