Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Oncollision detection and cut rope problem
#3
(18-11-2021, 09:06 AM)josemendez Wrote: Hi!

You're using contact.bodyA as the particle index (which it isn't), should be:

Code:
int particleIndex = solver.simplices[contact.bodyA];

then use particleIndex to access solver arrays.

Also, you're using the actor particle index (pa.indexInActor) to access the elements array, which does not make sense and may result in out of bounds access errors - this is why I think you're checking if the index is larger the elements array, which should not be necessary. Elements and particles are different things. To find the element that contains the particle you want, iterate trough the elements. Your TearRope code should look like this:

Code:
private void TearRope(ObiColliderBase col, Oni.Contact contact)
{

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

// retrieve the actor this particle belongs to:
ObiSolver.ParticleInActor pa = solver.particleToActor[particleIndex];
var actor = pa.actor as ObiRope;

// not a rope, stop:
if (actor == null) return;

// check rope elements and tear the one that references this particle:
foreach (var elm in actor.elements)
{
   if (elm.particle1 == particleIndex)
   {
      actor.Tear(elm);
      actor.RebuildConstraintsFromElements();
      break;
   }
}

}
I made the changes you mentioned, but I couldn't get the result I wanted. What I want is that when I bring the object (in my case it's a saw) to the rope it cuts the rope from that area. I have three rope in the environment. In the problem I have, when I take the saw to the rope, it cuts the wrong rope. moreover, it does not cut from the area I want.
There is something I'm doing wrong but I can't see what it is. Where do you think I should check?
Reply


Messages In This Thread
RE: Oncollision detection and cut rope problem - by greyhawk - 18-11-2021, 10:03 AM