Help Getting Length of Rope Between Two Points - 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 Getting Length of Rope Between Two Points (/thread-2331.html) |
Getting Length of Rope Between Two Points - anonzy - 23-06-2020 Hey, I was wondering if there was any way to calculate the current length of a rope between two specified control points. Is this possible? Thanks for the help! RE: Getting Length of Rope Between Two Points - josemendez - 23-06-2020 (23-06-2020, 01:00 AM)anonzy Wrote: Hey, Not built-in. However, can be done with a bit of coding. Ropes are made of particles connected by elements. Getting the length between any two elements in the rope is quite easy. You can take the CalculateLength() method in ObiRopeBase.cs as reference. It iterates over all elements in the rope, summing the distance between the two particles in each element. So instead of iterating trough them all, we can iterate trough a range of them: Code: float length = 0; Now, you could do some searching to know the element range between two given control points. The rope blueprint generates a ObiParticleGroup for each control point. Say we need to know the length between the second and the third control points: the first particle group will contain the index of the first particle of the first element. The second particle group will contain the index of the second particle of the second element. Hope that makes sense! Here's some code: Code: var group1 = rope.blueprint.groups[1]; // second cp |