Skip to content
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

fix: Issue with raycasting complex collision groups #2842

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

eonarheim
Copy link
Member

===:clipboard: PR Checklist :clipboard:===

  • 📌 issue exists in github for these changes
  • 🔬 existing tests still pass
  • 🙈 code conforms to the style guide
  • 📐 new tests written and passing / old tests updated with new scenario(s)
  • 📄 changelog entry added (or not needed)

==================

  • Fixed issue where raycasting with more complex collision groups was not working as expected
  • Added new feature to collision group raycasting, directly provide a collisionMask that you want to search for. Theoretically this is less confusing
const playerGroup = ex.CollisionGroupManager.create('playerGroup');
const notPlayersMask = ~playersGroup.category;
const hits = engine.currentScene.physics.rayCast(
  new ex.Ray(player.pos, playerDir),
  {
    maxDistance: playerSightDistance,
    // Search for all categories that match the mask
    collisionMask: notPlayers,
    searchAllColliders: false
  });

@eonarheim eonarheim merged commit 3edc04d into main Dec 4, 2023
6 checks passed
@eonarheim eonarheim deleted the bugfix/collision-group-raycast branch December 4, 2023 00:43
@itsscain
Copy link

itsscain commented Dec 4, 2023

solid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants