- Home /
Collision.impulse = 0 in OnCollisionStay Kinematic Static collision pair after Update
Hello. I have a piece of code that uses the impulse returned from OnCollisionStay. The script sits on a Kinematic rigidbody, and it is moved around the world by an external engine.
Previously, OnCollisionStay would return an impulse that would resolve the collision whenever the kinematic RB collided with a static collider, now, even though the collision is detected and returns the correct normal, Collision.impulse is always 0. When the Kinematic RB collides with other non-kinematic RBs, the impulse works, it is just broken for static terrain. This happened after updating to the 2019 Unity LTS release.
Is there some fix or good workaround for this issue?
If it works with a collision between the Kinematic RB and a static collider, then it looks like a bug to me (or maybe PhysX limitation?). It would be a good time to file a bug report, as the Terrain team is now working on improving it.
It doesn't work with a collision between a Kinematic RB and a static collider, only when a kinematic RB collides with some other RB. But yeah, this might be a bug, as it worked in 2018.3
It may not be a bug, but by design. A kinematic body won't apply any impulse to resolve a collision. When colliding with another RB, then the impulse is calculated as applied to the other RB, which can take it.
A possible workaround could be using Physics.ComputePenetration when the collision is detected. This provides a direction and a distance required to de-penetrate the colliders, which may be easily applied as impulse.