Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Adding pin constraints to a rope at runtime
#11
(18-03-2018, 06:44 PM)Gieve Wrote: fantastic!!! for those interested I added another call to a coroutine call DoLast that had a while(!generated) loop with a waitforseconds call of 0.1 second, when the rope set up coroutine finishes it sets the flag to true, then it set up the pin.

If there is a more eloquent way, i'd like to know. 

Thank you so so much for your help Jose.

sorry Chilly5 for hijacking your thread, was too similar to my issue to start my own.


Oh, I am unclear as to which variable controls the particle's mass, would you mind if I ask, so I can set those at generation as well.

Hi,

No need to do it in such a complicated way, you can simply wait for MoveNext to finish like this:

Code:
yield return ropemaker.MakeRope();
// you can not safely call any method that uses the rope:
ropemaker.AddPendulum();

or, if you don't want to call MakeRope inside a coroutine or use yield, you can just advance the coroutine yourself until it is done:
Code:
IEnumerator coroutine = ropemaker.MakeRope();
while(coroutine.MoveNext());
// you can not safely call any method that uses the rope:
ropemaker.AddPendulum();

To set the rope particle's mass, set their inverse mass (1/mass). Inverse masses are used because it is much more efficient in terms of performance, and because it avoids division by zero issues. See:
http://obi.virtualmethodstudio.com/tutor...icles.html
Reply