Obi Official Forum
Help Check if rope is wrapping or unwrapping? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Check if rope is wrapping or unwrapping? (/thread-2761.html)



Check if rope is wrapping or unwrapping? - Navvv - 23-02-2021

Is there any way to check if a rope is currently wrapping or unwrapping around a wrappable object? What about checking how many times the rope has wrapped around that object?


RE: Check if rope is wrapping or unwrapping? - josemendez - 23-02-2021

(23-02-2021, 03:40 AM)Navvv Wrote: Is there any way to check if a rope is currently wrapping or unwrapping around a wrappable object? What about checking how many times the rope has wrapped around that object?

There's no built-in way to do that. The definition of "wrapped" can change a lot depending on the game. Is it 2D or 3D? what conditions should the rope meet to consider it's wrapped? should the rope touch itself to determine if it's wrapped? should all particles between two points be in contact with the object? etc.

You can implement this yourself using the particle/collisions API and some math:
http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html
http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html


RE: Check if rope is wrapping or unwrapping? - Navvv - 24-02-2021

(23-02-2021, 08:37 AM)josemendez Wrote: There's no built-in way to do that. The definition of "wrapped" can change a lot depending on the game. Is it 2D or 3D? what conditions should the rope meet to consider it's wrapped? should the rope touch itself to determine if it's wrapped? should all particles between two points be in contact with the object? etc.

You can implement this yourself using the particle/collisions API and some math:
http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html
http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html

Thanks, those are helpful links. I'm still confused on how to determine if it is wrapped though. I am wrapping a rope around a 3D pole. One end of the rope is latched onto the top of that pole and the rest of the rope hangs down. The rope does not touch itself when it comes around, instead it goes around the pole in a helix sort of structure. Maybe I can check and see if all particles between two points on the rope are in contact like you suggested? I think that makes sense. Do you have any more tips?


RE: Check if rope is wrapping or unwrapping? - josemendez - 24-02-2021

(24-02-2021, 12:43 AM)Navvv Wrote: Thanks, those are helpful links. I'm still confused on how to determine if it is wrapped though. I am wrapping a rope around a 3D pole. One end of the rope is latched onto the top of that pole and the rest of the rope hangs down. The rope does not touch itself when it comes around, instead it goes around the pole in a helix sort of structure. Maybe I can check and see if all particles between two points on the rope are in contact like you suggested? I think that makes sense. Do you have any more tips?

Checking for contact of all particles does not guarantee it's wrapped as it does not give any information about the shape of the rope (it could just be laying parallel to the pole), but it's a start.

Off the top of my head, a promising method is to calculate the 2D polar coordinates of each particle with respect to the pole's centerline, and check that the angle increases monotonically: that the angle of every particle is larger than the angle of the previous one. That guarantees the rope goes in circles around the pole, and you could even count how many times it wraps around dividing the delta angle (last particle angle - first particle angle) by 360º. Couple that with all particles touching it, and you know it's tightly wrapped around it.