Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope Collision Detection
#1
Hi,
 I have 3 ropes tanged. I am untangling first rope and avoided collision from the other 2 ropes. How do I detect this ?
 I have the on collision subscribed on the solver and getting the contacts. But I want to filter rope wise

RopeGenerator.solver.OnParticleCollision += Solver_OnParticleCollision;

private void Solver_OnParticleCollision(ObiSolver solver, ObiSolver.ObiCollisionEventArgs contacts)
{
   
    if (contacts.contacts.Count <= 0)
    {
        
    }
    else
    {
        
    }
}
Reply
#2
Hi!

You can just check which rope the particles involved in each contact belong to. See "Retrieving the actor involved in a contact":
http://obi.virtualmethodstudio.com/manua...sions.html
Reply
#3
Hi,
 yes its partially working now. As I said I have 3 ropes and all 3 of them are in contact. But the below code only giving two rope collision. I 've set ids for each rope. 1, 2 and 3 in ropeOrder variable. I am getting only 2 and 3 in logs. top rope collisioin is missing. Am I missing something ? Do I have to consider c.bodyB somewhere ?

Code:
foreach (var c in contacts.contacts)
{
    int particleIndex = solver.simplices[c.bodyA];
    ObiSolver.ParticleInActor pa = solver.particleToActor[particleIndex];
    TangledRope tr = pa.actor.GetComponent<TangledRope>();
    tr.collided = true;
    tr.lastCollidedTime = Time.time;
    Debug.Log("pa: " + pa + ", actor: " + tr.ropeOrder);

}
Reply
#4
Contacts always take place between two things. Your code only checks one of the 2 particles involved in each contact,  so this will miss information. You need to do the same thing for c.bodyB.
Reply