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

BUG: RaycastAll fails to detect sleeping and static bodies at expected y position #198

Open
johnnyrainbow opened this issue Jan 9, 2024 · 2 comments

Comments

@johnnyrainbow
Copy link

johnnyrainbow commented Jan 9, 2024

I have found a bug where all Raycasts fail to detect intersections against the correct y position of sleeping or static bodies when the world has gravity, and their y positions are not grounded. (for example a floating static cube at y=5 in a world with -9.8 gravity will never be raycasted unless you cast only on the y axis.)

I made a code sandbox demonstrating the issue. https://codesandbox.io/p/sandbox/cannon-raycast-forked-x6yft5
(You can see in the console that it shows raycast results for only the non sleeping stacked cubes.)

@johnnyrainbow johnnyrainbow changed the title RaycastAll fails to detect sleeping body RaycastAll fails to detect sleeping and static bodies Jan 9, 2024
@johnnyrainbow johnnyrainbow changed the title RaycastAll fails to detect sleeping and static bodies BUG: RaycastAll fails to detect sleeping and static bodies Jan 9, 2024
@johnnyrainbow johnnyrainbow changed the title BUG: RaycastAll fails to detect sleeping and static bodies BUG: RaycastAll fails to detect sleeping and static bodies at expected y position Jan 9, 2024
@johnnyrainbow
Copy link
Author

Note for anyone following this or who has the same issue - I added my own temporary fix. The issue stems from the body aabb not updating due to it being either static or sleeping obviously (aabbNeedsUpdate is false), so the aabb is wrong when the raycaster interacts. I fixed it by adding another aabb (ghostabb) to Body class that does update for the sleeping/static body.

This way we can do the raycast against Body.ghostabb, and leave the real aabb as normal

@CrazyWords1
Copy link

Note for anyone following this or who has the same issue - I added my own temporary fix. The issue stems from the body aabb not updating due to it being either static or sleeping obviously (aabbNeedsUpdate is false), so the aabb is wrong when the raycaster interacts. I fixed it by adding another aabb (ghostabb) to Body class that does update for the sleeping/static body.

This way we can do the raycast against Body.ghostabb, and leave the real aabb as normal

Can u share your code? I don't understand

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

No branches or pull requests

2 participants