Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to control the length of a rope?
#1
Hi,

I want to have a rope hanging between two poles, representing an electrical cable. I created a rope object, assigned a line renderer to it and a curve editor. 
Inside the curve editor I positioned the two points at the positions of the two poles, selected the first and last particle and assigned a handle for each. The distance iteration property of the obi solver is at 3. On the rope the distance constrain stretching scale is at 0.01 and all stiffnesses at 1.

If I hit play now (the in-editor-playing doesn't work for me) the rope hangs inbetween both points correctly, but in the middle it stretches way more than I would like it to stretch (far through the floor).

I read a little bit in the forum but the solutions provided don't help me like decreasing the time step of our whole game. 

There must be a way to determine the length of a rope I believe? Could you give me a hint how to solve this issue?

Best regards,
Daniel
Reply
#2
Okay, let's try a simple yes-or-no question:
Could it be that it is technically not possible to determine the length of an Obi Rope without changing overall parameters like the time step?
Reply
#3
(17-09-2019, 11:22 AM)HenryChinaski Wrote: Hi,

I want to have a rope hanging between two poles, representing an electrical cable. I created a rope object, assigned a line renderer to it and a curve editor. 
Inside the curve editor I positioned the two points at the positions of the two poles, selected the first and last particle and assigned a handle for each. The distance iteration property of the obi solver is at 3. On the rope the distance constrain stretching scale is at 0.01 and all stiffnesses at 1.

If I hit play now (the in-editor-playing doesn't work for me) the rope hangs inbetween both points correctly, but in the middle it stretches way more than I would like it to stretch (far through the floor).
Increase the ConstraintGran sonrisaistance iteration value to 20.
Change the UV scale in Obi Rope Extruded Renderer: Y value = 3 or greater

Images attached below



I read a little bit in the forum but the solutions provided don't help me like decreasing the time step of our whole game. 

There must be a way to determine the length of a rope I believe? Could you give me a hint how to solve this issue?

If any of the developers were KIND ENOUGH to reply, this is a pain in the arse.

Here's my current work around which I absolutely hate.

1. obiRope.CalculateLength() - this is the true length of your rope. You want this value to be the distance in unity units
2. cursor.ChangeLength(distance); - this changes the rest length of the rope, but that is not the same as your true length

This is where it gets fucked up. Run a coroutine
while (obiRope.CalculateLength() == distance)
cursor.ChangeLength(obiRope.RestLength + or - a value); //do this until the Calculated Length matches your desired length



Best regards,
Daniel

(24-09-2019, 05:25 PM)HenryChinaski Wrote: Okay, let's try a simple yes-or-no question:
Could it be that it is technically not possible to determine the length of an Obi Rope without changing overall parameters like the time step?

Besides my above reply, make sure your pooled particles is large enough. You MUST reinitialize after you change this value and then re-setup your particles that were pinned.


Attached Files Thumbnail(s)
       
Reply
#4
I don't think I understand the original question. To determine the length of a rope (including any stretching/compression), simply do:

Code:
float length = rope.CalculateLength();

This works regardless of your rope/solver parameters, and will always return the actual length of your rope.

However, you also mention that the rope stretches too much. This is probably due to excessive rope resolution, resulting in lots of particles/constraints, that need a large amount of iterations and/or a short timestep to converge.

Also, having a distance constraint stretching scale of 0.01 will set the rope target length to 1% of its rest (initial) length. This is most probably not what you want, set it to 1 (100%) instead.

Code:
Okay, let's try a simple yes-or-no question:
Could it be that it is technically not possible to determine the length of an Obi Rope without changing overall parameters like the time step?

If by "determine" you mean "set", it depends. You can always correctly determine the length of the rope as I showed earlier, no matter what your parameters are. Now, whether the rest length of the rope can be reached at runtime (0% stretch), depends on whether your time budget (determined by the timestep and amount of iterations) is enough for the solver to do all the work. If it has to stop before reaching convergence (because you limited iterations to a low number, or have a large timestep), the residual error will manifest as unwanted stretching.

Note this is not specific to Obi, all iterative engines (99% of game engines/physics solvers) work like this.

Also, to change the simulation timestep you don't need to globally adjust the timestep of your scene if you can't/don't want to. You can just use substeps:
http://obi.virtualmethodstudio.com/tutor...olver.html
Reply
#5
Hi and thanks for your answers.
Unfortunately, I was not able to solve our issue.

What I tried according to the posts above:

Set "Distance Constraints" "Stretching Scale" to 1 -> No Difference
Increased amount of "Pooled Particles" to 1500 -> No Difference

Here is a screenshot of the settings:
[Image: Obi-Screenshot.png]
Reply
#6
Hi there,

The amount of pooled particles has no impact whatsoever in the simulation result. It only adds spare particles for the rope to be torn/resized.
What I suggested is to decrease the timestep, and/or increase the amount of substeps. The first one is a global physics setting, the second one is local to the solver. In PBD, error decreases quadratically with the timestep, so either should be extremely effective. Have you tried those?
Reply