I'd need a joint similar to the distance joint, but one which only limits how far apart two bodies can get, while still allowing them to rotate relative eachother.
Here are a few ideas I've thought of:
First one is to create/destroy a distance joint when the two bodies get too far apart. It would not limit their relative rotations, but it would be very tricky to know when to remove the joint. I can't just measure the distance between them since its locked by the joint... Catch 22...
Second option would be to use a prismjoint with a limit, but then the objects won't rotate relative eachother...
Third, I could "manually" adjust the velocities (and indirectly positions) of the two objects by hitting them with impulses as soon as they move too far apart. I'm not sure I could do this compensation in an accurate way though.
Would it be enough to simply apply the impulse in the direction of the other body, and scale it depending on the linear velocity away from that other body?
I thought I'd ask first before trying it myself, since these three solutions would be implemented differently (esp the last one) the way I'm hacking it together now. I'll begin testing the last method after I post this, better get input while I'm doing stuff so I can adjust without having to redo the whole thing after doing it all "wrong". 😀
Edit: There's also the option to actually create a new type of Joint I guess, but I don't understand enough about the inner workings of Box2D to attempt that...
Here are a few ideas I've thought of:
First one is to create/destroy a distance joint when the two bodies get too far apart. It would not limit their relative rotations, but it would be very tricky to know when to remove the joint. I can't just measure the distance between them since its locked by the joint... Catch 22...
Second option would be to use a prismjoint with a limit, but then the objects won't rotate relative eachother...
Third, I could "manually" adjust the velocities (and indirectly positions) of the two objects by hitting them with impulses as soon as they move too far apart. I'm not sure I could do this compensation in an accurate way though.
Would it be enough to simply apply the impulse in the direction of the other body, and scale it depending on the linear velocity away from that other body?
I thought I'd ask first before trying it myself, since these three solutions would be implemented differently (esp the last one) the way I'm hacking it together now. I'll begin testing the last method after I post this, better get input while I'm doing stuff so I can adjust without having to redo the whole thing after doing it all "wrong". 😀
Edit: There's also the option to actually create a new type of Joint I guess, but I don't understand enough about the inner workings of Box2D to attempt that...