How to do rope swinging?

It looks like this question has been asked a bunch of times. But none of the answers really answer my question. I want to make a game in which the player can do spiderman-like web swinging. To elaborate, spiderman attaches his web to some object and then, using his web as a rope, swings from that point. In this case, raycast to find where the player is aiming at, place an anchor there and start swinging from it. Simple enough, right? Yet I can’t for the life of me figure it out.

I’ve been struggling with this for the larger part of my night. Trying mostly with joints, even though I have little experience with them. I tried configurable joint linear limit, which really seemed to be it for a while, but it anchors the player to his own position and not the anchor. I tried changing the anchor settings of the joint, but that makes it all glitchy and weird. I tried placing a cylinder between the player and the anchor and attaching it to both but that was just a big mess from the start.

What’s the best way to do this sort of thing? I feel like there’s a stupid simple method I just haven’t thought of yet.

I found this article written by the guy who made Spider-man 2 about slinging in videogames. If you know a thing or two about game physics and C# like me, this might be the better option for you. I was able to implement this in a bit over an hour. Is a guide on implementing a rope similar to the one used in the Worms games.

Short answer:

  • Add a Dynamic Rigidbody2d Component to your hero
  • Shoot a Raycast from the hero towards the mouse/target (remember to use a layer mask!)
  • Stick a dummy object with a Kinematic rigidbody2d component at the collision point
  • put a distance joint2d on the dummy object, with the other end attached to you hero
  • Marvel at clean swinging motion