Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Climbing on rope and fix to move only on x, y
#12
When you cut a rope, the rope's last particle is still the same as it was before the cut. I mean, you still have only one rope, but with one discontinuity. Each piece after the cut is not an independent rope.

Cutting a rope at element "N", detaches the first particle of that element and creates a new second particle for the element before it. Like this:

O----O----O----O----O

Cut at element 2:

O----O----(O)    O----O----O

Depending on which half of the rope is still on the air, its last particle can either be "particle1" of the element you cut, or particle2 of the previous element.

Regarding your code, this is completely wrong:

Code:
rope.Tear(rope.elements[particleIndex]);

You can't access the elements array using a particle index. There's not the same amount of elements than particles, so this will often lead to an out of bounds access exception which you have checked for using the "if (particleIndex < rope.elements.Count) conditional". Furthermore, particles are rearranged whenever the rope is cut or resized, while elements are not. So after the first cut, this code will behave in very strange ways.

You need to pass an element index, not a particle index.
Reply


Messages In This Thread
RE: Climbing on rope and fix to move only on x, y - by josemendez - 25-10-2021, 08:49 AM