-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collision groups don't collide with self #2801
Comments
@ikiselev1989 This is a great question! Generally speaking collision groups do not collide with themselves, except for the special built-in group called In your example the group console.log(playersCanCollideWith.canCollide(playersGroup)); // true
console.log(playersCanCollideWith.canCollide(floorGroup)); // true
console.log(playersCanCollideWith.canCollide(enemyGroup)); // true A way to think about collision groups is as different "categories" (other engines like Unity call collision groups "layers"). Each group is represented by a 32 bit integer represented by a power of 2. So the groups in binary in your example are: playersGroup = 0b0001
npcGroup = 0b0010
floorGroup = 0b0100
enemyGroup = 0b1000 Each group also contains a By default the mask for a collision group is set to collide with every group apart from itself. playersGroupMask = 0b11111111_11111111_11111111_11111110
npcGroupMask = 0b11111111_11111111_11111111_11111101
floorGroupMask = 0b11111111_11111111_11111111_11111011
enemyGroupMask = 0b11111111_11111111_11111111_11110111 The The playersCanCollideWith = ~(0b0001 | 0b0100 | 0b1000) = 0b0010
playersCanCollideWithMask = ~(0b0010) = 0b11111111_11111111_11111111_11111101 Notice the final group is actually equivalent to the Apologies for the long explanation, hopefully that makes sense. Documentation/API QuestionI'll endeavor to improve the documentation here, and perhaps Excalibur needs to think about the API because it causes confusion. Perhaps we should rename the type |
@ikiselev1989 I've updated the docs with a more thorough explaination https://excaliburjs.com/docs/collisiongroups/ The team also spoke offline and we are potentially renaming this feature to |
Thanks a lot for your answer! Will deep into docs =) |
Going to close this for now! Let me know if you have any other issues! |
Hi!
There is not clear for me about collision groups.
I use this code from docs. And it's not working as I expect.
code
The text was updated successfully, but these errors were encountered: