Hi to all, im using RayCastSingle() in PhysicsWorld2D.cpp, but i have problem with collision filtering, here is my code:
define categories:
enum GAMELAYERS : const unsigned {
None = 0,
Character = 0x0002 ,
Platforms = 0x0004,
};
set character category bits:
boxCollider_ = GetNode()->CreateComponent();
boxCollider_->SetCategoryBits(GAMELAYERS::Character);
rigidbody_ = GetNode()->CreateComponent();
and raycast:
physicsWorld_->RaycastSingle(results, startPos, endPos, GAMELAYERS::Platforms);
i send platform bits as raycast collisionmask, but it still hit my character. i dont get it.
box2D collision filtering use this method:
uint16 catA = fixtureA.filter.categoryBits;
uint16 maskA = fixtureA.filter.maskBits;
uint16 catB = fixtureB.filter.categoryBits;
uint16 maskB = fixtureB.filter.maskBits;
if ((catA & maskB) != 0 && (catB & maskA) != 0)
{
// fixtures can collide
}
0x0002 & 0x0004 == 0
so whats the problem?
am i misunderstood how Category/Mask collision filtering works?