Obi Official Forum
Help A few technical questions - 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 A few technical questions (/thread-1362.html)



A few technical questions - Adrian_GSO - 12-09-2019

Hi, great asset btw. 

Is there a way to programmatically calculate the points of the rope? I wish for the rope to curl around a cylindrical object much like a firehose. 
And is there a way to programmatically force the rope to be a fixed length during set up?

Thank you so much.


RE: A few technical questions - Adrian_GSO - 24-09-2019

Hi, bumping up; still need the help!


RE: A few technical questions - BisuDagger - 24-09-2019

This code gets that available points inside the rope


Code:
       //ObiRope rope = obiRopeObj.GetComponent<ObiRope>();
       //ObiPinConstraintBatch pinConstraints = rope.PinConstraints.GetFirstBatch();
       //pinConstraints.AddConstraint(0, startConnectedObj.GetComponent<ObiCollider>(), startConnectedObj.transform.localPosition, Quaternion.identity, 0);
       //pinConstraints.AddConstraint(rope.UsedParticles - 1, endConnectedObj.GetComponent<ObiColliderBase>(),
       //                                                  endConnectedObj.transform.InverseTransformPoint(endConnectedObj.transform.position), Quaternion.identity, 0);


All theory here:
You could potentially loop through the batch of pinConstraints (rope.UsedParticles -1 is max size) and lock pins in to place by feeding them a Vector3 location. If you want it spaced evenly then you could take the distance and divide it by the usedparticles - 1. That would space it out equally. If you want, use a lerp function in a coroutine to find your desired points in space at run time. As you lerp to each new point, pin the particle at that location.