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

I did what you told me to do. It's now obiRope.UsedParticles-1. As you can see in this video, it works perfect for 6 particles (as Rope Length). But less than 6 particles, the rope behaves different which i couldn't understand. And for greater than 6 particles, it behaves exact same as 7 particles rope. I'm going out of my mind, help please Gran sonrisa



P.S. I have a prefab which contains the obiRope, WhiteSphere and the BlackSphere. As in prefab, spheres are pinned to the ends of the rope. And I have a script called MovePin. So the moving spheres with mouse, changing rope length due to distance between two spheres, changing rope UV scale and snapping rope ends to the block stuffs are made in MovePin script. And i have the script on both of spheres and each one works for itself. Maybe knowing that could help you figure out what's the problem.

Thanks in advance!

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];
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