Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Runtime Length Per Start/End Positions
#1
Hey!

I have an issue. Right now I am creating a very short rope with let's say 0.2 resolution which ends up creating 4-5 particles. This is perfectly fine on a short distance like this but I am also dynamically moving end point of the rope. Imagine a rope is tied to a stone (start) and a person just runs around carrying the other side (end) of the rope. On smaller distances, this is working really good however when the person gets away from the stone, 4 particles are no longer enough. What I want is to dynamically add / remove particles to the rope depending on the distance. Changing blueprint's resolution through code doesn't work but changing the blueprints resolution through editor works (to an extend, sometimes it just gets confused and throws lots of out of index exceptions).

I tried using ObiRopeCursor but since I am moving end point through code, it ends up adding particles in a very weird way. I think this is only supposed to work on stationary ropes?

I also tried starting with a large particle amount like 20-30. This is actually working the best but the issue in this one is, the moment I create the rope on runtime, since the distance between start and end points are very short (I am also dynamically creating the rope blueprint) it takes around 3 seconds for simulation to show a proper rope and until then it just flies around like you are suddenly entangling a very long rope.

Any suggestions are welcome.

Thanks in advance
Reply
#2
(14-03-2023, 03:13 PM)aderae Wrote: I tried using ObiRopeCursor but since I am moving end point through code, it ends up adding particles in a very weird way. I think this is only supposed to work on stationary ropes?

Hi!

The intended way to do this is using a cursor, works on both dynamic and static ropes. You can move the cursor to any point in the rope, and you can instantiate particles from any other point, so you can add copy particles from any point in the rope to the middle, the start, end, or any point you want, in either direction. Not sure what you mean when you mention it does it in "a very weird" way, but chances are you just need to adjust the cursor parameters. All sample scenes that resize ropes at runtime (Crane, GrapplingHook, FreightLift, etc) use cursors for this.

(14-03-2023, 03:13 PM)aderae Wrote: Changing blueprint's resolution through code doesn't work but changing the blueprints resolution through editor works (to an extend, sometimes it just gets confused and throws lots of out of index exceptions).

A blueprint is a "recipe" for building a rope from scratch. You can't change the blueprint of a rope that's loaded in the solver, doing this will result in out of index exceptions since the rope's actual physical shape and its blueprint will no longer match. If you want to change the blueprint at runtime, you need to take the rope out of the solver, modify its blueprint, then add it back to the solver. This is what the editor does every time you modify the blueprint via the path editor tools. This is absolute overkill for changing the length of a rope, though.

(14-03-2023, 03:13 PM)aderae Wrote: I also tried starting with a large particle amount like 20-30. This is actually working the best but the issue in this one is, the moment I create the rope on runtime, since the distance between start and end points are very short (I am also dynamically creating the rope blueprint) it takes around 3 seconds for simulation to show a proper rope and until then it just flies around like you are suddenly entangling a very long rope.

If you want to go this route, maybe you can reduce the rope's distance constraint's "stretching scale" parameter. This is basically a multiplier on the distance between particles in the rope, setting it to 0.25 will set the length of the rope to 25% of its rest length. Should work well enough unless your rope is self-colliding, in that case any particle overlap caused by setting its stretching scale to a small value will kind of "crunch" the rope.

kind regards
Reply