Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Issue with Rope Consistency!
#11
(10-06-2020, 08:12 PM)Kifwat Wrote: Okey that sounds good, but I think that will be easy just if the rope is straight and the two cubes move in a straight movement, so we can add edit the rope's length depending on the distance between the two cubes, but how can we do that when the rope is foldable and not straight? I mean in case the rope is stretched by other object's movement, how can we track that and then increase its length depending on the contact with the other object?

I don’t get your question.  Huh  The length of a rope is always the same regardless of it being straight, rolled up or folded in any position.

If you want to get the actual rope length including stretching -instead of its rest length-, just call rope.CalculateLength(). This will return the current rope length accounting for any stretching: the sum of all distances between each particle and the next one, so it’s really just the same as the case when the rope is straight. Check the API docs, and the crane example.
Reply
#12
(10-06-2020, 08:38 PM)josemendez Wrote: I don’t get your question.  Huh  The length of a rope is always the same regardless of it being straight, rolled up or folded in any position.

If you want to get the actual rope length including stretching -instead of its rest length-, just call rope.CalculateLength(). This will return the current rope length accounting for any stretching: the sum of all distances between each particle and the next one, so it’s really just the same as the case when the rope is straight. Check the API docs, and the crane example.

I mean after calculating the rope length including the stretching, how can I add particles between the ones who has a big distance between them (because of the stretching), to make the rope's particles always have the same distance between them, despite of the rope's length. Hope you understand what I mean Sonrisa
Reply
#13
(10-06-2020, 08:55 PM)Kifwat Wrote: I mean after calculating the rope length including the stretching, how can I add particles between the ones who has a big distance between them (because of the stretching), to make the rope's particles always have the same distance between them, despite of the rope's length. Hope you understand what I mean Sonrisa

I don’t think I get it... no matter how the total length of the rope is distributed across particle constraints (some might be very stretched, other not so much), the total rope length is the same. When increasing the length of the rope using a cursor, new constraints will always have the same rest length. This is taken care of automatically, I believe you’re overcomplicating things a lot: just call cursor.ChangeLength(new length) when the value returned by rope.CalculateLength() exceeds the rest length by some threshold. Pseudocode:

float length = rope.CalculateLength();
If (length > rope.restLength + threshold)
cursor.ChangeLength(length);
Reply
#14
(10-06-2020, 09:09 PM)josemendez Wrote: I don’t think I get it... no matter how the total length of the rope is distributed across particle constraints (some might be very stretched, other not so much), the total rope length is the same. When increasing the length of the rope using a cursor, new constraints will always have the same rest length. This is taken care of automatically, I believe you’re overcomplicating things a lot: just call cursor.ChangeLength(new length) when the value returned by rope.CalculateLength() exceeds the rest length by some threshold. Pseudocode:

float length = rope.CalculateLength();
If (length > rope.restLength + threshold)
cursor.ChangeLength(length);

Thanks for the code, the issue now is that the added particles stay fixed and didn't moves, and the code work for just one or two moves, and after that I got this error: 

IndexOutOfRangeException: Index was outside the bounds of the array.
Obi.ObiActor.SwapWithFirstInactiveParticle (System.Int32 actorIndex) (at Assets/Obi/Scripts/Common/Actors/ObiActor.cs:420)
Obi.ObiActor.ActivateParticle (System.Int32 actorIndex) (at Assets/Obi/Scripts/Common/Actors/ObiActor.cs:434)
Obi.ObiRopeCursor.AddParticleAt (System.Int32 index) (at Assets/Obi/Scripts/RopeAndRod/Actors/ObiRopeCursor.cs:118)
Obi.ObiRopeCursor.ChangeLength (System.Single newLength) (at Assets/Obi/Scripts/RopeAndRod/Actors/ObiRopeCursor.cs:203)
RopeScript.Update () (at Assets/Scripts/RopeScript.cs:28)

Can you make a quick video on this please, because I'm stuck on this all the day  Triste

Beside that, I think the perfect way to solve my problem -If it were possible- is to increase the number of particles to a higher number, but it's not possible to increase the resolution to more than 1.
Reply
#15
(10-06-2020, 09:41 PM)Kifwat Wrote: Thanks for the code, the issue now is that the added particles stay fixed and didn't moves, and the code work for just one or two moves, and after that I got this error: 


Can you make a quick video on this please, because I'm stuck on this all the day  Triste

Make sure you set its source mu to a location in the rope where particles aren't fixed. If you keep it at zero and the particle at zero is fixed, the cursor will take it as source and instantiate fixed particles.

Both the cursor mu and the source mu are normalized values: 0 means start of the rope, 1 means end of the rope. The source is the place where particles will be copied from, and the cursor the place where they will be added.

(10-06-2020, 09:41 PM)Kifwat Wrote: Beside that, I think the perfect way to solve my problem -If it were possible- is to increase the number of particles to a higher number, but it's not possible to increase the resolution to more than 1.

It is possible to set any resolution, it's only that the max resolution value is capped at 1 in the interface so that people don't go crazy with it, the need to use values higher than 1 is very rare as it gives diminishing returns. The more particles you have in your rope, the larger the performance impact, and the slower the simulation will converge. You will need more substeps to achieve the same stiffness, because there are more constraints in the system now.

To go past a resolution of 1, open up ObiRopeBlueprintBase.cs and comment out the [Range(0, 1)] attribute at line 15. You will now be able to enter any resolution value.
Reply