Rope swing game that attaches to any surface?

I am trying to make a game that lets me use a rope, which has been done before. However, I want to be able to connect to any surface, not just set points. Is this possible?

For sure. How do you envisage defining where the anchor point should go? Mouse click, touch, nearest object or something else?

mouse click, here’s a picture. I also want there to be a buffer, which i put in the image (if you click a little too high or too low it attaches to the nearest point to the mouse.)

You could put all the clickable objects that the rope can be anchored to into an object group. Then when the mouse is clicked, perform a raycast from player to mouse position, checking against the object group. The x & y variables will hold the point of contact between the raycast and the objects, with the x & y position in the parameters being the point where the raycast hits the edge closest to the player.

So this:


I believe will result in the raycast’s point of contact with a clickableBlock object being set in the variables xPos & yPos.

1 Like