Search code examples
iphonecocos2d-iphonebox2dcollision

Cocos2d - Is is possible to turn off collision for a Box2d b2Body with a b2FixtureDef?


I have a b2Body with a b2FixtureDef. I'd like to be able to turn off the ability of the b2Body to collide. Is this possible?


Solution

  • Yes it is possible. Make it sensor.

        b2FixtureDef fd;
        fd.isSensor = true;
        body->CreateFixture(&fd);
    

    Also with filter(fd.filter) you can specify collision specific to body.