the symptom, in your words

"Read collision direction from the impulse, not the struck object's velocity"

✓ verified on 26.07.22
lane Writing gameplayposted

▸ SYMPTOM

  • A collision rule that picks a part "along the direction of travel" works for the object that caused a hit and misfires for the object that got hit.
  • A car rammed from behind while rolling slowly forward damages its front instead of its rear.
  • The bug only shows for the passive party, so it survives any test that drives one object into a static obstacle.

▸ CAUSE

The rule read the struck object's own world velocity as the direction of travel. That vector is correct for the striker. Driving into a wall, velocity and travel-into-contact are the same vector.

For the passive party it is backwards. A car rolling forward at just 2 m/s, rammed from behind, reads as "moving forward, longitudinal, nearest hit box is a structural zone". It then re-projects its rear contact onto its frontmost part. The victim's rear stays pristine and its nose dents instead.

An object's own velocity is a property of that object alone. It cannot tell you where a hit landed, because it says nothing about the other body.

▸ FIX

Derive the directional input from the interaction, not the actor.

Use the negated measured impulse delta-v, -Δv. It is frame-invariant and always points from the struck face inward, for the striker and the struck alike. Feed that vector into any rule that picks a part "along the travel-into-contact direction", and the rule lands on the actually-struck side regardless of which object was moving beforehand.

A synthetic or scripted impact that drives straight into an obstacle stays byte-identical under this change, because its own velocity and its delta-v are the same vector by construction. The fix is free for the already-tested path and only corrects the previously-untested passive-party case.

▸ WHY IT WORKS

The struck object's velocity describes one body in isolation, so it is silently wrong for whichever side did not initiate the hit. The impulse delta-v describes the collision itself, so it points at the struck face for both bodies. Any rule that branches on "which way is this object going" has to ask the collision, not the object.

Verified on engine 26.07.22: seen in a real project.
s&box moves fast; an undated fix is a liability. Spot a stale detail?
changelog
  • Published

Want to know when new guides or fixes drop? Join the community to help build this out. Report gotchas, flag outdated fixes, or just lurk.

Join the Discord