Jump to content
  • Advertisement
Sign in to follow this  
ShishKabab

Collisions for sensors never registered in Box2DWeb

This topic is 2123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've created a body for the player which consists of a large block and a smaller block for the foot sensor. Even though I can see the foot sensor touching the ground (I've made it bigger just to be sure), I don't get a BeginContact (I've also triend PreSolve and PostSolve) event for the sensor (I do get one for the solid part of the body, but when only the sensor is touching the ground, I get no event). This is my code:

this.listener.BeginContact = function (contact) {
    var fixtureA = contact.GetFixtureA();
    var fixtureB = contact.GetFixtureB();
    var bodyA = fixtureA.GetBody().GetUserData(),
        bodyB = fixtureB.GetBody().GetUserData();

    console.log(contact.IsSensor(), fixtureA.IsSensor(), fixtureB.IsSensor(), fixtureA.GetUserData(), fixtureB.GetUserData());
    if(fixtureA.IsSensor()){
        bodyA.sensors[fixtureA.GetUserData()].active = true;
    }
    if(fixtureB.IsSensor()){
        bodyB.sensors[fixtureB.GetUserData()].active = true;
    }
};

The log prints: false, false, false, null, null (because only sensor fixtures have user data).

I've also tried making the body a bullet, like suggested in

What am I missing?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!