Minimum distance on configurable joint?

Is it possible to set a configurable joint to have a "minimum distance". For example to set the two connected objects not to be able to move within 10 units of one another. Obviously you can set a maximum distance (the linear limit) but I cannot find a minimum distance. If it doesn't exist then can anyone think of a way that I can implement it?

Thanks in advance!


If you actually move the joint anchor point say 20 unit in x, and set the linear limit to 10, then you end up with a joint that will prevent the two connected objects to be closer than 10 units, but you are then also limited on the maximum distance between the two, which will be in that case 30.

The solution ( untested ) would be to adjust the linear limit value in real time as the joint is evolving if you actually want to have unlimited or uneven maximum/minimum.

Also, could you describe why you are actually willing to do this, their might be other way around this problem. Are you trying to do technical rigs, or something like that?

One quick solution that I would test as well is to put hard limits using colliders, this might be sufficient for your problem. But be careful, the two connected bodies collider are not able to interact with each other ( very unfortunate, at least they could offer a toggle to enable it...), you'll have to build another collider parented to one of the connected body.

If you are stuck, I can provide a small example if that would help you progress.



The question is old i know, but google leads to this site everytime you search a solution for this issue :slight_smile:
In my case i solved this by adding 2 same joints vice-versa. One time from objA to objB and than from objB to objA, with a linearLimit distance.

So the objects are in a fixed distance between each other.

May not work for everyone, depends on the complexity of the joints.