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
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;
}
}
}
}
}