Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Problem with detecting collisions between different ropes
#1
I'm trying to detect collisions between multiple ropes with the code below. However, even if the colliding ropes are different, both pa.actor.gameObject and po.actor.gameObject point to the same object. Both bodyA and bodyB show the same rope. I want to detect different colliding ropes. I looked into the forum and believe that detection should be done with this method. However, I wonder if I'm making a mistake when creating the Rope or Solver.
solver.OnParticleCollision += Solver_OnCollision;

void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{

foreach (Oni.Contact contact in e.contacts)
{
// this one is an actual collision:
if (contact.distance < 0.01)
{
ObiSolver.ParticleInActor pa = solver.particleToActor[solver.simplices[contact.bodyA]];
ObiSolver.ParticleInActor po = solver.particleToActor[solver.simplices[contact.bodyB]];
if (pa.actor.gameObject != po.actor.gameObject)
{
Debug.Log("rope collides: " + pa.actor.blueprint.name + " " + po.actor.blueprint.name, pa.actor.gameObject);
}
}

}
}
Reply


Messages In This Thread
Problem with detecting collisions between different ropes - by murathan - 14-08-2023, 09:23 PM