This project has moved and is read-only. For the latest updates, please go here.

Keep a distance between two objects

Apr 1, 2009 at 12:57 PM
Hi everybody. Is there a way to keep a minimum distance between two objects? (in fact, I want to keep a distance between an object and every other object belonging to a specific tag). The slider joint doesn't work here as it keeps the distance between two specific points from each object, I don't know if I'm making me clear :S
Apr 1, 2009 at 11:16 PM
I'm just musing here,  but have you tried a slider joint with a max distance of PositiveInfinity?
Apr 2, 2009 at 2:08 AM
The problem with the Slider joint is that it keeps a distance from a specific point of the body, and what I want is to keep a distance from the whole body :/
Apr 2, 2009 at 2:22 AM
Then just set it up for the center of the body? that should work....
Apr 2, 2009 at 11:49 AM
But if both objects are rectangles, if I move one of them, at some point they will still collide, right? I mean, if they only keep distance from their center...
Apr 2, 2009 at 11:57 PM
Edited Apr 2, 2009 at 11:58 PM
not if the minimum distance between the two is greater than the length of half of the body.
rectangle is this long
but the minimum distance only has to be greater than half of that.
or go crazy
Apr 3, 2009 at 2:53 AM
Another thing you could do is set up a large invisible "shield" geom that is only set to collide with the geoms you want (via Collision categories)... Dunno why i didnt think of this at first!
Apr 3, 2009 at 5:42 AM
hahaha yeah, i was thinking of all these super complicated situations like having all the objects expel forces but set up specific force scenarios haha,
although the slider bar would work your idea would allow more freedom and be easier.
Apr 3, 2009 at 8:31 AM
RogueCommanderIX: You're right, is a very simple solution that should work. I should had think about that before.

Thanks a lot!

PS: Thanks tlegion for the help too :)
Apr 3, 2009 at 10:04 AM
You're welcome!