26-02-2019, 08:29 AM
(This post was last modified: 26-02-2019, 08:31 AM by josemendez.)
(25-02-2019, 09:29 PM)camirving Wrote: Hi there!
I have a rope and i've expanded its length.
I want to get the position of the particle that sits in the very middle of the rope, in normalized 0.5.
How can I retrieve a particle position via normalized value?
Use rope.GetConstraintIndexAtNormalizedCoordinate(normCoord) to retrieve the index of the distance constraint at a given normalized coord (0,1). Then, you can choose a particle at either side of the constraint by using GetStructuralConstraintParticles(constraintIndex, ref particle1, ref particle2). The indices returned by this function are actor indices, convert them to solver indices using rope.particleIndices[] and you're done. Code:
Code:
int constraint = rope.GetConstraintIndexAtNormalizedCoordinate(0.5f);
int p1,p2;
rope.GetStructuralConstraintParticles(constraint, ref p1, ref p2);
// I chose the first particle in the constraint. You could get fancier by choosing the one that's closer to the normalized coord.
Vector3 position = rope.Solver.positions[rope.particleIndices[p1]];