Adding collision to rope made using verlet integration

Godot Version

4.2

Question

Hi,

So I created a rope using something called verlet integration, basically a series of points that each store location values, which result in a pretty realistic rope.

My goal is to make this rope react to its environment, right now it does not have any collision detection whatsoever.

My question is, does anyone have an idea how one would add some sort of collision detection to this type of rope?

If this is not enough info, please let me know so I can provide more.
I am not sure if I am allowed to add links but here I go:

Thanks to anyone reading this!

You could put script into a rigidbody and put a collision shape. Then to solve the collision physics you could set the collision mask to look for your normal world object collision layer and use the body enter signal to then start your custom collision solver.

Thank you so much, I will try this

Hmm, I thought about this more… I still don’t know how this specific rope math works. For my previous idea to work each point needs its own rigid body. This may be too costly or not easily feasible with how the math works.

If rope segments and points are in an array and have a position you could setup an area2d+collision shape per point. (Rigidbody may be excessive, and as I think about it more may not work very well because warping bodies, by changing their position directly, my have strange behavior when moved like that. E.g. like not detecting a new collision!)

My second option would be to cast short rays in the direction of motion for each rope point. The target length and direction being the new position for the point. If the ray collids with something, meaning the rope would pass through the wold object, you only move it to the collision point. Then your next point you calculate will have the previous point position that collided with something.

Look at the casting ray tutorial and this class for Godot.

Thank you, I am trying a raycast solution right now, it is not working yet but I will let you know.