- Home /
Pushing objects away with spring joint
What I'm trying to do is have two objects loosely connected to one another such that they will resist being moved closer or further than a set distance from one another. I've been able to use a spring joint to get them to stay close together, but I'm having trouble enforcing the minimum distance constraint.
The spring joint has a Min Distance field that I assumed would do this for me, but it doesn't seem to be working. Nearby objects (well within the minimum distance) attached with a spring joint don't seem to have any influence on each other, and never push apart. However, if moved far apart they'll pull each other just fine. The minimum and maximum distances are within 0.02 of one another.
Am I misunderstanding the purpose of the joint, or simply misusing it?
Answer by Waz · May 23, 2011 at 10:40 PM
The minDistance and maxDistance are relative to the distance the objects were when the joint was created. Often you will simply set them both to zero - i.e. apply the spring whenever the bodies move from their initial relative distance.
Hey, first of all sorry for resurrecting thread from 10 years ago, but I'm having the same problem as the OP, and I can't see how your answer addresses the issue. The spring joint seems to only pull anchors together until they occupy the same place in space, but it doesn't push them apart like a real life spring would. Setting up $$anonymous$$Distance simply disables the force that pulls objects together once they're closer than specified, in my $$anonymous$$d it should apply the opposite force to keep objects at least $$anonymous$$Distance apart.
Your answer
