Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Rope cutting with collision
#1
Hello, I've copied the code in another Post to implement cutting Rope with collision.
It does cut the rope, but some rope does not get cut.
Turn out when I check the debug.log, it always cut the Rope02, but when I check in Inspector, the actual Rope is colliding with the cutter is Rope.
This implies my method of specify the Rope from solver.simplices and solver.particleToActor return wrong result.
I'll attached the project, please take a look.
https://drive.google.com/file/d/12hSpnv0...sp=sharing

Please check this video for more info


Code:
        private void TryTearRope(Oni.Contact contact)
        {
            var collider= ObiColliderWorld.GetInstance().colliderHandles[contact.bodyB].owner;

            // get the particle index:
            var particleIndex = solver.simplices[contact.bodyA];

            // retrieve the actor this particle belongs to:
            var particleInActor = solver.particleToActor[particleIndex];
            var actor = particleInActor.actor;

            //collide with a cutter
            if (collider.TryGetComponent(out RopeCutter cutter))
            {   
                //check if contact with cuttable
                if (actor.TryGetComponent(out RopeCutComponent cuttable))
                {
                    var rope = cuttable.rope;
                    //pass all checks
                    Debug.Log($"cutter {cutter.name} cut the rope {rope.name} at particle {particleIndex}");
                    // check rope elements and tear the one that references this particle:
                    foreach (var elm in rope.elements)
                    {
                        if (elm.particle1 == particleIndex)
                        {
                            rope.Tear(elm);
                            rope.RebuildConstraintsFromElements();
                            break;
                        }
                    }
                }
            }
        }
Reply


Messages In This Thread
Rope cutting with collision - by spikebor - 31-07-2023, 09:11 AM
RE: Rope cutting with collision - by josemendez - 31-07-2023, 11:05 AM
RE: Rope cutting with collision - by spikebor - 31-07-2023, 04:24 PM