Doing ropes in Corona physics engine

Most people would start with the rope by taking the chains sample in Corona sample code and modifying it to make the segments short newRect’s. At least I did. The resulting “rope” is stiff and a bit unrealistic, and very persnickety in what it can hold without stretching/breaking. So - some hints to make the rope smooth as butter:

  1. Call physics.setContinuous( false ) right after physics.start(). This makes the joints behavior MUCH more reasonable.

  2. Make the rope segments overlap a little - by 2 pixels or so.

  3. Make each rope segment a sensor - add isSensor=true to your addBody parameters. This would make it so your other objects cannot collide with ropes, but then you probably didn’t want them to anyway. The important part here is that the segments don’t “collide” with each other.

  4. Make rope segments’ density relatively high compared to things it holds.

  5. Make sure that the joints are set in the middle of the rope segment (that is, if its thickness is 3, that the joint is in the middle pixel of the 3). Otherwise the physics would cause it to favor one side over the other when it bends.

  6. Modify the rope’s “stiffness” by setting the joints’ rotation limits. I use:
    [lua]J.isLimitEnabled = true
    J:setRotationLimits( -35, 35 )[/lua]
    for a fairly “loose” rope.

Enjoy. [import]uid: 160496 topic_id: 29761 reply_id: 329761[/import]

Try this approach: bezier curve controlled by longer segments…

https://developer.anscamobile.com/code/not-verlet-rope [import]uid: 8271 topic_id: 29761 reply_id: 119434[/import]

These are very good suggestions.

As far as making them sensors go, you can do that. But the most important part like you said is to make sure the segments that are overlapping do not collide with each other. What works for me is using 2 collision filters. The odd numbered segments get one, the evens get the other. That way the ropes can collide with other objects if you want and 2 ropes can’t pass through each other. [import]uid: 40137 topic_id: 29761 reply_id: 119443[/import]

You can also use the new Rope Joint. I tryed and it works really good. [import]uid: 77183 topic_id: 29761 reply_id: 122036[/import]

You can also use the new Rope Joint. I tryed and it works really good. [import]uid: 77183 topic_id: 29761 reply_id: 122036[/import]

I searched everywhere and can’t seem to find a single example of the new rope joint. Even Corona’s docs are lacking. Does anybody have a Corona rope joint example, or can point me in the right direction? And why aren’t the “rope” samples updated to use this new joint? [import]uid: 9075 topic_id: 29761 reply_id: 136775[/import]

Is it in the latest daily build docs (which are not the same as the public online docs)? [import]uid: 8271 topic_id: 29761 reply_id: 136777[/import]

I searched everywhere and can’t seem to find a single example of the new rope joint. Even Corona’s docs are lacking. Does anybody have a Corona rope joint example, or can point me in the right direction? And why aren’t the “rope” samples updated to use this new joint? [import]uid: 9075 topic_id: 29761 reply_id: 136775[/import]

Is it in the latest daily build docs (which are not the same as the public online docs)? [import]uid: 8271 topic_id: 29761 reply_id: 136777[/import]