@bysreg what do you mean by canceling collision? 1) do not call collision callback 2) do not allow for objects to collide and let them pass through each other?
the "contact->SetEnabled(false)" will cancel the collision between that two fixture. so, originally, the two fixtures will collide but i want in some cases they dont collide
I've managed to turn collisions off and on (in this case an open lid of a box that I wanted a ball to pass by at launch but bounce off later in the game once the lid was closed) using:
lidBody:setActive(false)
lidBody:setActive(true)
No idea if that's legitimate as box2d is mostly suck it and see for me, but it worked for what I wanted to do.
Comments
what do you mean by canceling collision?
1) do not call collision callback
2) do not allow for objects to collide and let them pass through each other?
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
b2WorldManifold worldManifold;
contact->GetWorldManifold(&worldManifold);
if (worldManifold.normal.y < -0.5f)
{
contact->SetEnabled(false);
}
}
the "contact->SetEnabled(false)" will cancel the collision between that two fixture. so, originally, the two fixtures will collide but i want in some cases they dont collide
Likes: Yan
yes, that solve the problem. what i do is set it to sensor when pre-solve, and set it to non-sensor in post-solve
local contact = event.contact
contact:setEnabled(false)
end