I am currently testing the Arcade Physics collision categories, as I can see that they exist not only in Matter but also in Arcade.
Here’s the proof:
So I made a Sandbox test, where I have 4 types of collision objects that can collide between each other.
this.categories = {
playerMelee: 1, // 2^0 -> 0b0001
playerRanged: 2, // 2^1 -> 0b0010
enemyMelee: 4, // 2^2 -> 0b0100
enemyRanged: 8 // 2^3 -> 0b1000
};
I set the object’s body to the respective category.
container.body.setCollisionCategory(categories.playerMelee);
container.body.setCollidesWith([categories.enemyRanged, categories.playerRanged, categories. enemyMelee]);
Then I add the colliders with this.physics.add.collider
for each group separately.
At certain time, I want to disable one of those to avoid colliding with others, with for example:
this.playerRanged1.body.removeCollidesWith(this.categories.playerMelee);
But this simply does not work.
If I change to Matter physics, it works. So I guess it’s a bug with the Arcade?
My game is simple and I don’t need Matter with it’s complexity, so I want to use Arcade. Any suggestions?
Here’s my sandbox test, just drag them around and check the logs. Please check: