Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detect Collision between rope and collider
#1
I have 3 ropes in my scene, all of them inside one Obisolver, and they collide with the ground and also some walls. I want to make a condition that return true when all those ropes didn't collide with any wall (but still colliding with the ground), I tried the script below but it didn't work properly, I mean the condition return false even a rope is still colliding with the wall, I think it's because there's 3 ropes in the same ObiSolver, how can I solve this please?

Code:
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
   {
       frame = e;

       for (int i = 0; i < e.contacts.Count; ++i)
       {
           if (e.contacts.Data[i].distance < 0.1f)
           {
               Component thecollider;
               if (ObiColliderBase.idToCollider.TryGetValue(e.contacts.Data[i].other, out thecollider))
               {

                   if (thecollider.CompareTag("Wall"))
                   {
                       TouchingWall = true;
                   }
                   else
                   {
                       TouchingWall = false;
                   }

               }
           }
       }

   }
Reply


Messages In This Thread
Detect Collision between rope and collider - by Kifwat - 19-05-2020, 06:25 PM