Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About PinConstraint Scripting
#5
(22-02-2018, 08:20 PM)josemendez Wrote: Hi,

If you're changing the rope lenght at runtime using ObiRopeCursor, keep in mind that you're adding particles mid-rope (or wherever the cursor is). So of course the most recently added particle is not at the end or the beginning of the rope!. UsedParticles-1 will become the most recently added particle, not the one at the end.

What you need to do if you always want to get the first and last particle indices in a dynamically resized rope is to work with segments (distance constraints). They are always consecutive, the first particle in the first distance constraint will always be the particle at the beginning of the rope, and the last particle in the last distance constraint will be the particle at the end of the rope.

Code:
ObiDistanceConstraintBatch batch = rope.DistanceConstraints.GetFirstBatch(); // or GetBatches()[0] for pre-3.3
int firstParticle = batch.springIndices[0];
int lastParticle = batch.springIndices[batch.springIndices.Count-1];


i love you! i love you! i love you! i love you! i love you! i love you! i love you! i love you! i love you! i love you! i love you! 

thank you sooooooooooooooooooooooooooooooooooooooooooooo muuchhhhhh!!!!! Corazón Corazón Corazón Corazón
Reply


Messages In This Thread
About PinConstraint Scripting - by Cannias - 21-02-2018, 09:49 PM
RE: About PinConstraint Scripting - by josemendez - 22-02-2018, 08:58 AM
RE: About PinConstraint Scripting - by Cannias - 22-02-2018, 07:50 PM
RE: About PinConstraint Scripting - by josemendez - 22-02-2018, 08:20 PM
RE: About PinConstraint Scripting - by Cannias - 22-02-2018, 09:18 PM