Contact hit events #613
Labels
A-Dynamics
Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on
C-Enhancement
New feature or request
C-Usability
A quality-of-life improvement that makes Avian easier to use
Note: This probably shouldn't be implemented before some contact improvements I'm working on, like a contact graph and contact type API improvements.
Games often only care about getting contact events for shapes that collide at a significant enough speed (or force). This can be used to trigger some sound effect or particle effect, or to apply damage.
In Box2D, this exists is in the form of "Hit Events":
In
bevy_rapier
, there is instead aContactForceEvent
:I think Box2D's approach of using an "approach speed" is generally more intuitive than having to deal with forces, since forces are mass-dependent and can get very large. However, forces or impulses can also be valuable if mass should be taken into account. So we could have both:
Or alternatively, we could have a single
ContactHitEvent
that stores both the approach speed and impulse, and aHitEventThreshold
component that is an enum or has two thresholds:bevy_rapier
also provides a total force vector and total force magnitude, but I don't think we need them. We should just have helpers for contact types so that you can queryCollisions
and compute them with methods there.The text was updated successfully, but these errors were encountered: