Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Get position of particle at end of rope
#3
Hi,

Particle order changes when you resize or tear the rope. On a 10-particles long rope, you can't assume #0 being the first and particle #9 being the last.

----------

However, elements are guaranteed to be sorted. These are the "edges" that link each particle in the rope to the next one.

You can use the rope's GetElementAt() method to get the element at a given normalized coordinate (0 being the start of the rope, 1 the end). Eg:

Code:
var element = GetElementAt(0,out float elementMu);
index1 = element.particle1; // first particle in the rope
index2 = element.particle2;

-----------

As you know, the ObiPathSmoother generates an intermediate representation of the rope that is used for rendering (see: http://obi.virtualmethodstudio.com/tutor...modes.html)

You can also get smoothed path positions along the rope, instead of working with raw particles/elements. For this you can use the path generator's GetSectionAt() method, that also takes a normalized coordinate as input. For instance, if you wanted to place an object at a position and orientation:

Code:
var generator = GetComponent<ObiPathSmoother>();
ObiPathFrame section = generator.GetSectionAt(m);
YourObject.transform.position = generator.transform.TransformPoint(section.position);
YourObject.transform.rotation = generator.transform.rotation * (Quaternion.LookRotation(section.tangent,section.binormal));

----------

Quote:I also tried the solution from this thread, which needed a bit of updating. I'm not sure if I'm doing this correctly. I am getting a solver index of 0 for both the first and last particle.

That thread is quite old, won't work in Obi 5.X and up. You're getting the first and last particles from the first batch in the blueprint. You should be getting the first particle from the first batch, and the last particle from the last batch in the solver. For details, see:
http://obi.virtualmethodstudio.com/tutor...aints.html

It's way easier to use either of the above methods.

let me know if I can be of further help. cheers!
Reply


Messages In This Thread
RE: Get position of particle at end of rope - by josemendez - 07-04-2021, 10:21 AM