Rope that can be 'thrown' from a player?

Hey guys, my first post here!

I have been playing around with making ropes, using pivot joints.

Basically my code has a player throw a ball, which ultimately needs to have a rope attached.

I have done this, however the rope is created on a timer which essentially works out the angle and distance between the ball and player, and then creates the rope.

What I really want to achieve is for the rope to be created of a pre determined length, and for the ball to be thrown from the player, ‘pulling’ all the rope out.

Anyone have any suggestions on how I could achieve this? Really enjoying Corona :slight_smile:

Hi @fraser.ollason,

This is an interesting proposal, but I think it’s possible. What I would try is to have each of the rope parts (segments) as sensor objects (so they don’t physically collide with each other), then basically bunch them up in a spring/zigzag arrangment overlapping the ball. So, consider if each segment is a tiny rectangle, join them up in a zigzag arrangement like the top example in the image, but then ultimately compact/push them all together like the bottom example in the image. That way, when the ball flies off, the rope will sort of “unwind”.

Brent

Thanks Brent, I have attempted just that actually. I have tried to avoid using sensor objects however as I want them to have a physical property as I am trying to throw the rope over an edge, and have the player then pull himself along the rope.

Further to this however, I want the end of the rope to freeze when it detects a collision with a wall, which I have setup correctly. I can’t however get the end to freeze in place, it seems the rope wants to contract back to the player. Any thoughts on this?

Basically when there is a collision currently I am setting the end of the rope to static, and linearvelocity to 0. Any other ideas? Without the rope in place, I can successfully throw the ‘end rope’ piece, and ‘stick’ it to the wall.

Hi again,

I actually realized after posting initially that my sensor advice was incorrect. Objects joined together should not actually collide with each other. This is already standard Box2D behavior, so you don’t need to actually make your rope segments into sensor types.

As for sticking the end of the rope to a wall, I would suggest that upon collision, you join the rope’s end to the wall (or other object) using a weld joint. That should be perfectly reliable without trying to change the rope’s end to “static” or anything like that. Also, it will easily give you the ability to destroy the weld joint when you want to release the rope from that hold-point.

Best regards,

Brent

Hi @fraser.ollason,

This is an interesting proposal, but I think it’s possible. What I would try is to have each of the rope parts (segments) as sensor objects (so they don’t physically collide with each other), then basically bunch them up in a spring/zigzag arrangment overlapping the ball. So, consider if each segment is a tiny rectangle, join them up in a zigzag arrangement like the top example in the image, but then ultimately compact/push them all together like the bottom example in the image. That way, when the ball flies off, the rope will sort of “unwind”.

Brent

Thanks Brent, I have attempted just that actually. I have tried to avoid using sensor objects however as I want them to have a physical property as I am trying to throw the rope over an edge, and have the player then pull himself along the rope.

Further to this however, I want the end of the rope to freeze when it detects a collision with a wall, which I have setup correctly. I can’t however get the end to freeze in place, it seems the rope wants to contract back to the player. Any thoughts on this?

Basically when there is a collision currently I am setting the end of the rope to static, and linearvelocity to 0. Any other ideas? Without the rope in place, I can successfully throw the ‘end rope’ piece, and ‘stick’ it to the wall.

Hi again,

I actually realized after posting initially that my sensor advice was incorrect. Objects joined together should not actually collide with each other. This is already standard Box2D behavior, so you don’t need to actually make your rope segments into sensor types.

As for sticking the end of the rope to a wall, I would suggest that upon collision, you join the rope’s end to the wall (or other object) using a weld joint. That should be perfectly reliable without trying to change the rope’s end to “static” or anything like that. Also, it will easily give you the ability to destroy the weld joint when you want to release the rope from that hold-point.

Best regards,

Brent