Closed mattjennings closed 4 months ago
Fairly certain this is due to adjusting contact.normal
. Digging into the ArcadeSolver some more, now I see mtv
affects the position (which is correct in my repro - the box resolves to where it should be) and normal
affects the velocity, so that would explain why it gradually increases until it bypasses the collider completely. Though I'm not seeing anything obvious yet https://github.com/excaliburjs/Excalibur/blob/7a4c82115311f75169fc880150ed06b754a5f365/src/engine/Collision/Solver/ArcadeSolver.ts#L199-L205
Ahh, contact.normal
also needs to be biased to 1/-1 depending on which is colliderA 🤦♂️ my fault. This caused if (bodyB.vel.normalize().dot(normal) < 0) {
to be skipped (as it would be 1
) and vel would keep increasing.
I think I had spoke with @eonarheim a while ago about adding a way to bias a contact to a collider, so that all of these tricks are done for you. Something like contact.bias(self)
. That might be the best solution to avoid user error. I'll close this now since it's not a bug.
Steps to Reproduce
Run this repro here: https://jsfiddle.net/mattjennings/Lmtdrx3y/7/
The box will correctly stop on the slope. If you swap the lines
to
this will cause
box
to be colliderB in the precollision. When this is the case, the box eventually falls through the slope after about a few seconds.My running theory is the collider is not properly updated according to mtv, as the collision point seems to fall further and further down until it completely passes the slope collider.
Expected Result
Box should stay on the slope when it is colliderB in precollision
Actual Result
Box eventually falls through the slope
Environment
next
since it included a collision perf refactor, but sadly same result)Current Workaround
Swapping collider A & B around in the precollision handler does seem to fix it... but I am sure there are consequences to doing that 😅