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

Add ability to cancel events or at least react before the collision physics occurs. #24

Closed
stephanemagnenat opened this issue Sep 30, 2020 · 2 comments · Fixed by #120
Closed
Labels
C-Enhancement New feature or request

Comments

@stephanemagnenat
Copy link

Box2D and its derivative have a preSolve event that is fired when two colliders or sensors are about to get into contact, giving the user code the possibility to cancel the contact. This is for example useful in two cases:

  • for platforms that can be climbed from the bottom, but are solid in the top, as in Super Mario,
  • when one of the object is supposed to be destroyed by the user logic when it touches the other, before the collision occurs.

As far as I've read in the documentation, Rapier currently only provides post world step events.

If proximity events Proximity::WithinMargin would be fired for collider-collider interactions, possibly these could be used for hacking around this limitation, but as the documentation says, due to the speed of movement they might be skipped, so that does not seem like a solution.

@stephanemagnenat
Copy link
Author

This might be a duplication of #3, so maybe my comment above could be moved there.

@sebcrozet
Copy link
Member

Yes, this sounds like something we will want to add. Maybe we could even make it more flexible and allow other kinds of effects like modifying the contact normal, friction coefficients, etc. right before the solver takes them into account.

I wouldn't say this is a duplicate of #3 because #3 would filter pairs out before contacts are actually computed. With what you propose here, contacts would be computed as usual, but the way these contacts are handled by the solver can be modified by the user. I think this can actually be seen as a superset of #25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants