Optimizing physics

Hmm. Here’s a recreation of my simple box example, using native AmmoJS calls:

The box goes to sleep after the (I believe) default 3 second sleep timer

1 Like

I found a pg prepared that shows the problem, i think.

(settings related to this comment)
scene.getPhysicsEngine().setGravity(new Babylon.Vector(0,-1,0);

For this first example, it seems like it could be considered a bug in babylon, it’s just a bad default value though. It could be that setting the default value to 1 would cause buggy behavior elsewhere. In the second example with the cylinder on the ground.

see line 15:


Now, try commenting it out out and change the values around.
(note) commenting it out is the default babylon behavior (perhaps should be changed).

try each of these and replay:


The behavior when you comment out line 15 is buggy and inconsistent. It seems setting this value to some value but greater than 0 by default could fix some issues for falling objects. It doesn’t help for rolling objects though (see ex below)


I made the same changes to your pg, using 5 as a default value seems pretty good. But, thats mainly because it doesn’t fall over.

i added a timeout to modify setting the settings after 5 seconds to show the difference here. It still doesnt settle though. It starts to behave nicely, but then it’s like there is some constant acceleration and vibration that leads to catastrophic resonance. is there some dampening setting? maybe that could stop it going apeshit after like 30 seconds.

setting the timestamp to 1 in the settimeout callback in this example caused a halo-like super jump. I googled about that, and it said its caused by the player (cylinder here) falling through the level and the engine applying a a very strong impulse to counter-act it. maybe something similar is happening?


1 Like

Things are looking a bit grim it seems… No good to have an engine with some bugs that can’t be fixed :frowning: Also it seems that Ammo.js has been a bit abandoned so… Time to invest creating that RapierPlugin for Babylon? :smiley:


As far as I’ve seen Rapier could be the best alternative.


@Cedric and @RaananW, I guess we should dig into this ? this is so sad Physix engines gets abandoned like this :frowning:

cc @Deltakosh


A Rapier plugin could be a very nice addition, I agree