You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arcade Physics Collision Categories Not Working as Expected #7034
Phaser Version: 3.87.0
Operating system: Windows 11
Browser: Chrome 109.0.5414.120
Description
I am currently testing the Arcade Physics collision categories, as I can see that they exist not only in Matter but also in Arcade. However, they do not seem to work as expected.
Here’s the proof that collision categories exist in Arcade:
However, this does not work. The object continues to collide.
If I switch to Matter Physics, this functionality works as expected. Since my game is simple and I don’t need Matter's complexity, I prefer to use Arcade Physics. I suspect this is a bug specific to Arcade Physics.
Example Test Code
Here’s my sandbox test. Drag the objects around and check the logs: Sandbox Test Link
Additional Information
The logs demonstrate that the collision categories are not being updated when calling removeCollidesWith. This suggests a potential issue with the implementation of Arcade Physics collision categories.
Hi @frederikocmr, the solutions seem to be adding setCollisionCategory and setCollidesWith to the groups as well because you are using groups in the colliders.
Hi @frederikocmr. We have added checks for individual game objects having it's own unique collision categories within a physics group. The issue seems fixed and it has pushed it to the master branch. It will be part of the next release. Do test it out and let us know if you encounter any issues.
Activity
zekeatchan commentedon Feb 10, 2025
Hi @frederikocmr, the solutions seem to be adding
setCollisionCategoryandsetCollidesWithto the groups as well because you are using groups in the colliders.Here's what the code looks like:
Try adding this to your sandbox and see if it works as expected.
frederikocmr commentedon Feb 17, 2025
Hi. Thank you @zekeatchan!
I update the code as you mentioned and it seems like it works, but with a few caveats.
For example:
To disable the collision between a ranged unit and all the other melee units, I use this:
But it only works, if when I add the collider, the playerRangedGroup is the first argument, like this:
It does not work if I do like this:
This will also not work in case playerRangedGroup is the first argument of the collider:
But why?
Here's the updated Sandbox link:
https://phaser.io/sandbox/aFiGN93v
Fix phaserjs#7034. Adding `collisionMask` and `collisionCategory` che…
zekeatchan commentedon Mar 19, 2025
Hi @frederikocmr. We have added checks for individual game objects having it's own unique collision categories within a physics group. The issue seems fixed and it has pushed it to the
masterbranch. It will be part of the next release. Do test it out and let us know if you encounter any issues.