Moving meshes (e.g. mesh.position.y = 3) AFTER creating a BoxImpostor during initialization phase (means before first physics update cycle) causes a big initial velocity.
This is only the case with the CannonJSPlugin.
const SHOW_BUG = true;
var box = BABYLON.MeshBuilder.CreateBox("box", {}, scene);
if (!SHOW_BUG) { box.position.y = 3; }
var impostor = new BABYLON.PhysicsImpostor( box, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 1}, scene);
if (SHOW_BUG) { box.position.y = 3; }
just like computeWorldMatrix that sometimes needs to be forced, if you change the position in a single frame after initializing you can force an update which prevents this issue - https://playground.babylonjs.com/#6HFBC4#2 .
I agree that it is not optimal, you can add an issue on github (you can assign me), but in the meantime I will recommend forcing the impostor update or setting the position prior to creating the impostor
Thx for the quick response. I filed an issue on github but (as it seems) Iām not allowed to assign it to anybody.
Yes, my report already hints the countermeasure you suggest, it just took me half a day to find out and I ran across issues of other people with the same root cause (like this https://www.babylonjs-playground.com/#1RKZXB#6 , which also can easily be fixed by moving the positioning code). So it is at least confusing.