Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manual tearing via cript
#21
(16-01-2020, 01:22 PM)zakur0 Wrote: Bump!

If the rope tearing is automatic using tear resistances, is there an event or a way to figure out the particle indices where the cut occurred, so you can apply a texture to fill the rope from the inside?

There's no automatic callback (it's in our TODO list though). For now you can iterate over the rope's elements array. Each element holds 2 particles together, and they are sorted from the start of the rope to the end. So if you find two elements such that:

Code:
element.particle2 != nextElement.particle1

It means the rope is torn there.
Reply
#22
(16-01-2020, 04:32 PM)josemendez Wrote: Hi there!

In 5.0, you don't need to remove constraints before and add them after. A single call to  RebuildConstraintsFromElements(); after tearing as many elements as you need will do. We still need to update the docs regarding this.

Code:
public class Tear : MonoBehaviour
{
   public ObiRope rope;

   public void Update()
   {
       if (Input.GetKeyDown(KeyCode.Space))
       {
           rope.Tear(rope.elements[10]);
           rope.RebuildConstraintsFromElements();
       }
   }
}

You can see an example of how its used in ObiRope's ApplyTearing() method, which is what is called each frame when automatic tearing is enabled.

thank you, that did it! yes please update the docs Gran sonrisa
Reply