Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manual tearing via cript
#20
(15-01-2020, 04:09 PM)Sether Wrote: I'm trying to accomplish this same thing, however the advice given in the thread is out of date. I have a tearable cable with one end attached to an object with the other end dangling like a strand of hair. i call rope.tear(rope.elements[10]) and sure enough the new particle spawned does the infinite mass thing and falls away, with the rest of the now cut rope acting as still connected to the original rope.  i would have expected it to cut and fall away as a whole piece of course. 

I've tried removing and re-adding the constraints before and after the tear (refactored from the code here to match the latest version of the asset) , but I cant seem to get a proper reference to the newly spawned infinite mass particle so i can assign the correct mass to it.

Here's my cut method:

Code:
   [ContextMenu("Test Cut")]
   public void Cut()
   {
       TestRope.GetConstraintsByType(Oni.ConstraintType.Distance).RemoveFromSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).RemoveFromSolver();        
       TestRope.Tear(TestRope.elements[10]);
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).AddToSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Distance).AddToSolver();
       TestRope.GetConstraintsByType(Oni.ConstraintType.Bending).SetEnabled(true);
       TestRope.solver.UpdateParameters();
   }



i expect when this is figured out i will still need to fix the cut rope not falling away as well. 

any advice?

Thank you!

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.
Reply


Messages In This Thread
Manual tearing via cript - by Kalidor - 09-10-2017, 10:29 AM
RE: Manual tearing via cript - by niZmo - 09-10-2017, 11:32 AM
RE: Manual tearing via cript - by josemendez - 09-10-2017, 02:13 PM
RE: Manual tearing via cript - by ctalDai - 31-07-2019, 06:48 AM
RE: Manual tearing via cript - by Kalidor - 10-10-2017, 09:56 AM
RE: Manual tearing via cript - by josemendez - 10-10-2017, 10:28 AM
RE: Manual tearing via cript - by Kalidor - 10-10-2017, 11:51 AM
RE: Manual tearing via cript - by josemendez - 10-10-2017, 03:14 PM
RE: Manual tearing via cript - by Kalidor - 10-10-2017, 03:44 PM
RE: Manual tearing via cript - by x-lab - 19-10-2017, 11:12 AM
RE: Manual tearing via cript - by josemendez - 19-10-2017, 11:43 AM
RE: Manual tearing via cript - by x-lab - 19-10-2017, 12:13 PM
RE: Manual tearing via cript - by josemendez - 19-10-2017, 01:09 PM
RE: Manual tearing via cript - by x-lab - 19-10-2017, 03:34 PM
RE: Manual tearing via cript - by josemendez - 19-10-2017, 04:13 PM
RE: Manual tearing via cript - by x-lab - 20-10-2017, 11:14 AM
RE: Manual tearing via cript - by josemendez - 20-10-2017, 11:58 AM
RE: Manual tearing via cript - by Sether - 15-01-2020, 04:09 PM
RE: Manual tearing via cript - by josemendez - 16-01-2020, 04:32 PM
RE: Manual tearing via cript - by Sether - 17-01-2020, 10:10 AM
RE: Manual tearing via cript - by zakur0 - 16-01-2020, 01:22 PM
RE: Manual tearing via cript - by josemendez - 16-01-2020, 04:37 PM