Suppose I have the following entity:
EntityBase {
id: platform
entityType: "anEntity"
width: 100;
height: 100;
BoxCollider {
id: collider
bodyType: Body.Dynamic
collisionTestingOnlyMode: true
categories: Box.Category1
collidesWith: Box.Category2 | Box.Category3
fixture.onBeginContact: {
timer.start();
if (contact begin with category 2) {
}
else {
}
}
fixture.onEndContact: {
if (contact end with category 2) {
}
else {
}
}
fixture.onContactChanged: {
if (now contacting with category 1 and category 2) {
}
}
}
}
The collider states only contact with Category 2 and Category 3. Is there a quick and easy way to retrieve which category the entity is colliding with? I’m currently having to do the following:
fixture.onContactBegin: {
var fixture = other
var body = other.getBody()
var entity = body.target
if (entity.entityType === "AnotherEntity") {
// do something
}
}
This doesn’t feel clean and I’m wondering if there’s an easier way to get which category the entity is colliding with.
Cheers!