Box2D Forums

It is currently Thu May 23, 2013 5:49 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Sensor or AABB problem
PostPosted: Tue Nov 29, 2011 2:40 am 
Offline

Joined: Fri Oct 29, 2010 1:47 am
Posts: 29
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?


Top
 Profile  
 
PostPosted: Tue Nov 29, 2011 3:28 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
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.


Top
 Profile  
 
PostPosted: Tue Nov 29, 2011 2:55 pm 
Offline

Joined: Fri Oct 29, 2010 1:47 am
Posts: 29
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;
      }


Top
 Profile  
 
PostPosted: Wed Nov 30, 2011 7:48 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
ah I see. Yes it's pretty much the same thing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: psbot [Picsearch] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group