Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Rope is moving wen increasing his length
#1
Hi,

I wanted to increase the length of a rope toward a maximal length. I used a code based on manual :

Code:
void Update()
{

    if (_obiRope.restLength <= _lengthMax)
    {      
         _obiCursor.ChangeLength(_obiRope.restLength + 0.2f * Time.deltaTime);
    }
    else
    {
         Debug.Log("Can't increase more");
    }
}

However, in runtime I observed a weird behavior : https://imgur.com/a/geSDfoW. The length of the rope is increasing, but at the same time the rope is moving in the direction of the cursor.
Is there anything I'm doing wrong ?
Reply
#2
Is the rope attached to something? Seems to be just floating in zero gravity... changing rope length will add inertia: new particles = more mass, which gets added to the rope suddenly (since ropes are discretized, not continuous) and this mass is not placed where it would minimize energy. The result is altered momentum.

Generally speaking, you can't assume momentum conservation while resizing ropes at runtime. This is not an issue if the rope is under any external forces since these are generally much larger than any spurious energy added by the cursor, but in zero gravity and zero damping this will almost always cause the rope to start moving.
Reply
#3
(08-02-2022, 11:46 AM)josemendez Wrote: Is the rope attached to something? Seems to be just floating in zero gravity... changing rope length will add inertia: new particles = more mass, which gets added to the rope suddenly (since ropes are discretized, not continuous) and this mass is not placed where it would minimize energy. The result is altered momentum.

Generally speaking, you can't assume momentum conservation while resizing ropes at runtime. This is not an issue if the rope is under any external forces since these are generally much larger than any spurious energy added by the cursor, but in zero gravity and zero damping this will almost always cause the rope to start moving.

No it isn't attached to something and indeed it is floating with zero gravity. It's more clear why it's moving, thanks for the physical explaination.

I add a floor and gravity to reproduce the experiment with "external forces", it seems a bit more stable but when it reach the max length it start moving as before. Does this mean that the "external forces" are not "larger" enough ?

Or should I restrain the expansion rate factor (the one before Time.deltaTime) ?
Reply
#4
(08-02-2022, 01:38 PM)lufydad Wrote: No it isn't attached to something and indeed it is floating with zero gravity. It's more clear why it's moving, thanks for the physical explaination.

I add a floor and gravity to reproduce the experiment with "external forces", it seems a bit more stable but when it reach the max length it start moving as before. Does this mean that the "external forces" are not "larger" enough ?

Or should I restrain the expansion rate factor (the one before Time.deltaTime) ?

Gravity in this case acts in a direction that's completely perpendicular to the rope's longitudinal axis: it will not affect momentum along the X axis in the slightest. What I mean when mentioning gravity, is that ropes are usually attached from either end to an object and tend to fall down and lay in a vertical fashion, so any momentum gains are quickly dissipated.

The floor won't affect horizontal momentum either, unless you use a collision material with non-zero friction: the rope is free to slip on the floor. So this is still behaving exactly like (or very close to) the original scene since both external forces act in an axis that's perpendicular to the momentum.

What is your use case exactly? Maybe I can give more specific pointers if I know what you're attempting to do.
Reply
#5
(08-02-2022, 02:45 PM)josemendez Wrote: Gravity in this case acts in a direction that's completely perpendicular to the rope's longitudinal axis: it will not affect momentum along the X axis in the slightest. What I mean when mentioning gravity, is that ropes are usually attached from either end to an object and tend to fall down and lay in a vertical fashion, so any momentum gains are quickly dissipated.

The floor won't affect horizontal momentum either, unless you use a collision material with non-zero friction. So this is still behaving exactly like (or very close to) the original scene since both external forces act in an axis that's perpendicular to the momentum.

What is your use case exactly? Maybe I can give more specific pointers if I know what you're attempting to do.

Unfortunately in my case the rope is blowing up... That's why I try to make a simple example with a free rope floating in the air which showed the unrealistic behavior that I described above. But, thanks to your answer, I understand this behavior.

By the way, my "real case" is a rope which is attached to a boat and floating in sea (I made a system which compute buoyancy and drag force against the wave for each particles).
Do you think that increasing the rope from the boat should change the moment little enough to prevent this kind of behaviour ?
Reply
#6
(08-02-2022, 03:00 PM)lufydad Wrote: Unfortunately in my case the rope is blowing up... That's why I try to make a simple example with a free rope floating in the air which showed the unrealistic behavior that I described above. But, thanks to your answer, I understand this behavior.

It's unrealistic, but unfortunately the only way to "fix" it would be to use a true continuum model of the rope (where mass and volume are completely tied to each other = constant density, and bend/stretch deformations are coupled) which means ditching particle-based solutions entirely and using FEM or something akin. As far as I know, no existing realtime physics engine does this.

(08-02-2022, 03:00 PM)lufydad Wrote: By the way, my "real case" is a rope which is attached to a boat and floating in sea (I made a system which compute buoyancy and drag force against the wave for each particles).
Do you think that increasing the rope from the boat should change the moment little enough to prevent this kind of behaviour ?

If the rope is attached to a boat and floating around under drag forces, this should work ok.

Here's the results I get with a rope that's attached at one end, zero gravity and mild isotropic drag (damping). As you can see the momentum gain is redistributed along the entire rope, which makes it flutter a bit as it grows (doesn't grow in a straight line) but otherwise it works well:

Reply
#7
(08-02-2022, 03:20 PM)josemendez Wrote: It's unrealistic, but unfortunately the only way to "fix" it would be to use a true continuum model of the rope (where mass and volume are completely tied to each other = constant density, and bend/stretch deformations are coupled) which means ditching particle-based solutions entirely and using FEM or something akin. As far as I know, no existing realtime physics engine does this.


If the rope is attached to a boat and floating around under drag forces, this should work ok.

Here's the results I get with a rope that's attached at one end, zero gravity and mild isotropic drag (damping). As you can see the momentum gain is redistributed along the entire rope, which makes it flutter a bit as it grows (doesn't grow in a straight line) but otherwise it works well:

Do you have an idea, to make it grow in a straight line ?

In my case, I have this "rolling effect" :  https://imgur.com/a/5QKZ8wX.
In your point of view, is this an excepted behavior ?
Reply
#8
(08-02-2022, 03:50 PM)lufydad Wrote: Do you have an idea, to make it grow in a straight line ?

In my case, I have this "rolling effect" :  https://imgur.com/a/5QKZ8wX.
In your point of view, is this an excepted behavior ?

Yes, this is the expected and intended result. Note this is what would happen in real life too, and is not related to the momentum gain I explained before: even with perfect momentum conservation, coiling would take place.

Imagine trying to reeling out a rope to the floor in a straight line:

would it magically keep straight on it's own, assuming there's no one pulling it straight as you reel it out? no chance! you'd have to rely on pushing the already reeled out rope it in a *perfect* straight line as you reel out more rope, and make sure there's absolutely zero resistance to rope motion (no mechanical friction). The slightest perturbation would cause it to start rolling and waving around. In physics, this effect is called "coiling".

It might help to attach two points on the rope, instead of just 1: a single point has rotational freedom on all 3 axis, but two points define a direction (and so they only have rotational freedom on one axis). This would force the rope to come out in a straight line, however, it's free to coil further down the attachment unless it's extremely rigid. Here's a video of the results by attaching a couple points to constrain orientation:



As you can see, it starts out straight and only starts bending when there's quite some rope reeled out.
Reply
#9
(09-02-2022, 09:06 AM)josemendez Wrote: Yes, this is the expected and intended result. Note this is what would happen in real life too, and is not related to the momentum gain I explained before: even with perfect momentum conservation, coiling would take place.

Imagine trying to reeling out a rope to the floor in a straight line:

would it magically keep straight on it's own, assuming there's no one pulling it straight as you reel it out? no chance! you'd have to rely on pushing the already reeled out rope it in a *perfect* straight line as you reel out more rope, and make sure there's absolutely zero resistance to rope motion (no mechanical friction). The slightest perturbation would cause it to start rolling and waving around. In physics, this effect is called "coiling".

It might help to attach two points on rope, instead of just 1: a single point has rotational freedom on all 3 axis, but two points define a direction (and so they only have rotational freedom on one axis). This would force the rope to come out in a straight line, however, it's free to coil further down the attachment unless it's extremely rigid. Here's a video of the results by attaching a couple points to constrain orientation:


As you can see, it starts out straight and only starts bending when there's quite some rope reeled out.

That's what I thought, I just wanted to be sure. Thanks for the tips for the straight rope !
Reply