dimforge / rapier.js

Official JavaScript bindings for the Rapier physics engine.
https://rapier.rs
Apache License 2.0
418 stars 57 forks source link

Changing RigidBody bodyType before any collisions makes rigidBody static #267

Closed frankieali closed 2 months ago

frankieali commented 7 months ago

With a simple scene such as a ball dropping onto a plane, if the dynamic rigid body is set to "fixed" after a few steps and then back to "dynamic" after a few more steps before colliding with the plane, then it will become stuck, unaffected by gravity as if it were still fixed. Once another object collides with it then it will begin to move again.

frankieali commented 7 months ago

For example, as seen in this demo: https://react-three-rapier.pmnd.rs/dynamic-type-changes The Suzanne monkey head is falling as a dynamic object. On mousedown of the model, it toggles to kinematic. Refresh the page and try to catch the Suzanne monkey head before it hits the floor with your pointer. Once you release your pointer, the head will no longer fall even though it's dynamic again. Then drag the head all the way down until it intersects the floor (you may need to zoom out). After that first collision intersection, the bodyType changing seems to work as expected.

frankieali commented 2 months ago

Seems to have been fixed here https://github.com/dimforge/rapier/blob/master/CHANGELOG.md#v0190-05-may-2024 Fix kinematic bodies not being affected by gravity after being switched back to dynamic. Thanks!