Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Collide between two ropes
#2
(11-02-2020, 01:44 PM)tda777 Wrote: I'm using Obi Rope 5.1 and i need detect collisions (or lack of collisions)  between two ropes. I put two ropes with different tags under common Obi Solver and and I received messages from ObiSolver.OnCollision.

Code:
   private void M_ObiSolver_OnCollision(ObiSolver solver, ObiSolver.ObiCollisionEventArgs contact)
   {
       foreach (Oni.Contact contactItem in contact.contacts)
       {
           ObiSolver.ParticleInActor pa = solver.particleToActor[contactItem.particle];

           Component collider;
           if (ObiCollider.idToCollider.TryGetValue(pa.actor.GetInstanceID(), out collider))
           {
               //avoid floor collision
               if (collider.CompareTag("floorTag"))
                   return;

               if (contactItem.distance < 0.01)
               {

                   if (!pa.actor.CompareTag(collider.tag))
                   {
                       print($"rope({pa.actor.name}) touched another rope({collider.name})");
                   }
                   else if (pa.actor.CompareTag(collider.tag))
                   {
                       print($"rope({pa.actor.name}) touched itself({collider.name})");
                   }
               }
           }


       }
   }

But i did not get collider of another rope. 
How I can get collision between two ropes?

Ropes do not use colliders. They use particles. That's the whole point of a particle-based physics engine.  Guiño  

To get the particle-particle collision events that happened during a frame, subscribe to solver.OnParticleCollision. The contact will contain the indices of the 2 particles involved, instead of a particle index and a collider index.
Reply


Messages In This Thread
Collide between two ropes - by tda777 - 11-02-2020, 01:44 PM
RE: Collide between two ropes - by josemendez - 11-02-2020, 02:42 PM