I’m running into a problem, where I want to update a physics impostors mass after it has been created. I’m using the method setMass, according to the docs: PhysicsImpostor | Babylon.js Documentation
The code increases the mass every 2 seconds by 1kg. After one or two times, the sphere begins to shoot into the sky. In the commented out code below, I basically did the same thing, like the cannon physics plugin does (see: Babylon.js/cannonJSPlugin.ts at master · BabylonJS/Babylon.js · GitHub) but this seems to not have this issue (Edit: Though, I didn’t check if the new mass is actually applied properly).
Yes, this is an edge case. When mass increases, small penetration in the ground happens. And the physics engine responds just like it’s a collision and the sphere bounces.
I just tried with AmmoJS and it seems to better handle this case.
Oh and another thing I observed, when the object is in mid-air and the mass gets updated, there is clearly a change in velocity visible. I updated the playground with a lower gravitiy where it’s easy to observe this behaviour: https://playground.babylonjs.com/#BEFOO#1628
I had the same issue in my project, where there’s zero gravity applied and the object was floating without any contact/collision. However I can’t tell for sure if there is another issue which causes this.
I’ve debugged and it’s the same code that’s being executed.
Changing in velocity might be an issue with cannon solver. does it repro with other engines?
Maybe cannon stores forces appplied to object and a change in mass will also change linear velocity.