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

I would like to find the position of the particle at one end of a rope, no matter how much it has been resized at runtime. 

I have a rope with two control points and two particle attachments. The top attachment is static and the bottom is dynamic. I'm looking to reset an object to the end of the rope (on the dynamic attachment), and to do this I want to either move the rope to the object, or the object to the rope. They are both within close proximity of each other.

I tried to get the solver index of that particle using the rope's blueprint: 
Code:
int solverIndex = defaultRopeBlueprint.groups[1].particleIndices[0];
Vector3 worldPos = rope.GetParticlePosition(solverIndex);

This seemed to work, but if I change the length of the rope at runtime, I get a position that doesn't make sense. 

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. 

Code:
ObiConstraintsBatch batch = (ObiConstraintsBatch)rope.GetConstraintsByType(Oni.ConstraintType.Distance).GetBatch(0);
int lastParticle = batch.particleIndices[(batch.constraintCount - 1) * 2 + 1];
int firstParticle = batch.particleIndices[0];
Vector3 worldPos = rope.GetParticlePosition(firstParticle);
//or
Vector3 worldPos = rope.GetParticlePosition(lastParticle);

Thank you!
Reply


Messages In This Thread
Get position of particle at end of rope - by cfinger - 07-04-2021, 12:41 AM