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

Variable-length chain/rope

Topics: Developer Forum
Feb 9, 2010 at 2:30 AM

Hi...I'm new to both XNA and Farseer. I've read through the various threads involving creating ropes/chains. I'm trying to implement two bodies connected by a variable-length rope, i.e., one where the length of the rope either lengthens or shortens depending on the distance between the two bodies. Based on information already in the forums, I've implemented a pretty decent fixed-length rope between two bodies that gives the basic effect I'm looking for. 

Now I'm interested in having the length of the rope change as the bodies move. How would I go about doing that, and what would be the best way? I'm using CreateChain with LinkType.RevoluteJoint. Is there a way to dynamically update the width of each body in the chain? Or do I want to add or delete bodies to the chain as the two connected bodies move?

Feb 10, 2010 at 10:28 PM

If you are just drawing a line between each body, and not drawing the bodies themselves, then you can just adjust the localanchor points of the joints. If you use a pin joint instead of a revolute joint you can just set the distance apart instead of the anchors.

The above way if how I would suggest doing a rope, because if you are drawing the bodies themselves you would have to resize them and that could get ugly. eg: you make a body longer and it encapsulates a nearby object.