Sensor or AABB problem

Hi, I have a problem with sensors. They seem to sense collisions even if the sensor is not colliding with an object. As long as the sensor is not too far away, it says there is a collision.
This is annoying because my character has a sensor underneath his feet, and when he jumps, he can jump again before he hits the ground because the sensor thinks it is colliding with the ground.
Same with bullets, they explode before hitting objects because their sensors say there is a collision when there isn't yet.

How can I fix this?
It sounds like you are using the contacts from the world's contact list...? If so make sure you check that the contact IsTouching(). Contacts in that list only mean that the AABBs of two fixtures are overlapping, but not necessarily that the fixtures themselves are also touching.
btw the more efficient way is to use a contact listener.
irresistible force wrote:
It sounds like you are using the contacts from the world's contact list...? If so make sure you check that the contact IsTouching(). Contacts in that list only mean that the AABBs of two fixtures are overlapping, but not necessarily that the fixtures themselves are also touching.
btw the more efficient way is to use a contact listener.


Thanks irresistible force! 🙂 that completely fixed it. I am not getting them from the world's contact list, but from the specific body's contact list. Is this ok?

Code:
ContactEdge ce = m_body.getContactList();
      while ((ce != null))
      {

         if (ce.contact.isTouching())
         {
                if ((ce.contact.m_fixtureA.isSensor()) || (ce.contact.m_fixtureB.isSensor()))
                   m_bTouchingGround = true;
            
         }
         ce = ce.next;
      }
ah I see. Yes it's pretty much the same thing.

Original thread: https://box2d.org/forum/viewtopic.php?t=7911