Download

Ropey rope physics of the non-colliding unphysics rope.

Hello,

I’ve been working on creating a grappling hook device, that could be used by players to throw onto higher ledges and then climb up with. Unlike the “standard” game grappling hooks used by the likes of batman and that just cause 2 dude I can never remember the name of, I’ve been trying to create more of a portable ladder that somewhat forms itself around simple geometry than a thing that pulls the character to a point on a wall. With the first few attempts I experimented with skeletal meshes of ropes, which I only ever managed to horribly glitch out at the slightest movements. Then I’ve tried to use the cable components attached to two physics objects with a physics constraint between them, but the cables do not have collisions, so I’ve been trying to find a way to form them around corners using multiple cables attached to each other.

So far I’ve managed to get it to work almost like I want them to under strict laboratory like conditions. Here’s some screenshots, where I’ve turned the cable component length to 1 and the segments down to make it stop falling into the floor just so I can see them better for now.

68349017813e98e335811235c7686e7b.pngfd0f19b265f0a89b0e7c606a9e6ecebc.png7111ffc47c0c414fb045bf0016719bab.png70e08e25fe64702fd836a813c4b16bde.png284f7b41b4f80b4d63b6d74fc80d6fbb.png

Basically what I’ve done so far is trying to find the shortest path over any obstacles between the two objects. First checking whether there’s straight line of sight between the objects, then if not, check if there’s a trace possible between them at the higher object’s Z value, if still not, increasing the Z of both until a trace was possible. Then using some of the trace hit locations and normals to determine and place the points of rope around the object corners. Because I’ve only got one hard constraint between the objects and not the rope itself, it could in theory go over an infinitely high wall if both objects were dropped on opposite sides, so I added a force that pulls both objects towards each other or the centre point when the rope length exceeds the maximum desired length. Which lets me keep a relatively consistent length around things and pull one end and have the other one move along the line of the rope. I’ve also added a capsule component along the rope that scales with the length of the rope that I can use for some kind of ascending/descending mechanics, which I haven’t done yet.

It’s super buggy and easy to exploit by just throwing one object behind a wall or around a corner and having a rope magically appear on the top of it or how to make sure that it goes around an edge with overhangs and not through floors, as well as maybe adding more break points to better fit on more complex geometry. So I’m really just posting this to see if anyone has any clever ideas about how to approach something like this or has a better solution entirely.

Ah yes and I’m doing this entirely in blueprints, because I still haven’t learned C++ enough to deal with any kind of real problems with it.

Came came to say this looks great! Keep us updated.

My initial approach was unfortunately wrong for the intended purpose of the device. I looked at it from a static perspective and how to find the shortest distance between two objects around obstacles, which would create a decent enough end result if you didn’t care how the objects got to their positions. But seeing as this is intended to be more of a dynamic object that’s going to be thrown around, a different approach is necessary. So I’m now running a line trace between the two objects, if that trace hits anything it will create a bend point at the first hit location and make it go back to a straight line when the trace between objects doesn’t hit anything. A much simpler solution to the single bend point problem.

But having only a single bend point isn’t really that great. Especially when objects you want to throw it over have some depth to them. So I’m making the objects run another line trace, now to the first bend point and seeing if there’s any collisions along the way. Whenever they hit another object it will create another bend point at that new location and will remove it when they stop getting hits with the new object. I also managed to create a minimum distance between bend points so that very thin objects wouldn’t use up both bend points.

At it’s current state it has the basic functionality that I wanted it to have. However, I’m thinking that it would probably be possible to create a system that automatically generates new bend points indefinitely if I could set the cable components “attached to” location during runtime. Currently I can only manipulate one end of a cable component and have to tie the other one to a predefined object and then toggle the visibility of any unused cable components when they’re not needed. Maybe someone clever comes along and tells me how to change the attachment point and then I can spend yet more time on increasing the bend limit.

There are currently a few issues with making it work equally well both ways (depending on which object moves after the initial break) but that won’t be a problem if I can change my cable attachment points around. Otherwise I’ll have to create secondary cables that are only visible in certain situations, which is less than an ideal solution. But for now I will start working on the player movement altering component that players will be able to use for climbing up things.

And some screenshots for good measure:
4d01943c844e452d760c7b1e963d4003.png 4d1f2c51fc1a74cf7f081131f58dde30.png
Notice how in the second one the cable goes through the glass block because both bend points are used up before it reaches it. But it shouldn’t have any functional drawbacks as a climbing device if the level design doesn’t require you to climb over very complex geometry and even then it wouldn’t be that bad because of the limited length of the cable.

I have finished the initial functional version of my grappling hook device. It is somewhat buggy, it’s not pretty and it doesn’t quite work smoothly to be in an actual game yet. But hey, it works. Here’s a short 2 minute video of me using it to climb onto a building and then move along some rooftops to get some epic loot at the highest point.

https://youtube.com/watch?v=HvLi5gTdf44

It starts off with a silly loading screen, then I proceed to pick up 6 grappling hooks from the ground next to me. Open the inventory to drop them by placing them on the “drop item slot”. Then fail at throwing it onto the roof the first time, because my mouse went outside the game window. Throw it up there and hit my interact button to grab the rope and climb up it with the forward movement key. The character gets a movement impulse in the look at rotation of the lower point towards the bend point and works both ways, up and down. You could at any point let go of the rope and fall down and also grab the rope mid air if it’s stationary. (If it was moving, the capsule component would move away from the character and make you fall.) I then proceed to throw it over various roof edge profiles and climb over them. As a (temporary) measure I’ve made the jump button move you higher up on the Z axis, just so it’s easier to get over the walls. Finally I reach the top platform where I look back towards the ropes I left behind (which I could’ve picked up again and reused, so I would’ve only needed one total) and I equip some items and knock myself out. (Yes, I fixed the spawn locations of the hat and weapon upon death, which were the wrong way around.)

The problems I’m having now are with the bend points being placed on the surface of the geometry. so they are somewhat inside the blocks close to the points. I’m thinking that I could possibly create some kind of offset using either the angle of the rope and bend point compared to the world xyz or by using the hit normals to make it slightly stand off the surface (which would look better than being inside the surface at any point). Another thing is trying to get the capsule transitions to stop breaking the grab and to move smoothly from one to the next and make some kind of better system for getting over obstacles that the rope is bent around. I would also like to somehow snap the player location to be along the rope vector, so that it would also be possible to create an animation for climbing that looked right along the rope. If I could somehow fix the player to be attached to the rope, it might be possible to swing around on a rope while it’s moving. I might also need to work a little on the which way is up and which way is down, because right now it can be a little confusing when the rope is mostly flat and not at an incline due to forward input moving you towards whichever end is higher up and backward input moves you toward the lower side.

If anyone has any ideas or info how to solve any of the problems I’m still experiencing, let me know. :smiley:

Really cool work! I’ve always loved grappling hooks and I like how you added a skill element instead of just aiming where you want to go. Very creative.

I’d love to see it where the player was holding the end of the rope and scaling the side of a wall.

How crazy looking is your blueprint?

It’s not that bad really, just about fits into the minimum zoom of the blueprint view. And a lot of it just the same process copy pasted to apply to different variables.
2968032b79f8fdad795a647960159001c7f15aa3.png

I was also considering how it could be used if it was equipped on the character. Ie. mouse1 throws it out and your character would dangle on it with some kind of physics constraint, so you’re able to climb things without having to manually drop it out of your inventory every time you want to use it. I might do that after I’ve looked into improving my character’s ability to climb over lower obstacles without help from grappling hooks and stuff. I still need to keep some element of skill and to a degree slowness of use to not turn it into a superhero ability to get anywhere instantly.

@OP, I suggest making the collision capsules use CCD - that should make it so you can have the capsules fit to the rope size and still not fall through the floor.

Since you won’t have a ton of volumes I assume, having them use CCD should be acceptable.

Awesome work - physics rope grappling hooks are something that way too few games actually try to do.