24-09-2019, 07:27 PM
This code gets that available points inside the rope
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.
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.