How to enable / disable gravity?

I want to be able to switch between the two.

see lines 170 - 173

checkbox2.onIsCheckedChangedObservable.add(function(value) {
if(scene.isPhysicsEnabled) scene.disablePhysicsEngine();
else scene.enablePhysics(); // TODO: doesnt work

I can disable it, but I can’t enable it again

You can but you have to run all the setup again (like setting the impostors).

Isn’t there a variable for gravity itself? Where I could set it to 0 for example and afterwards return it to its original value (without disabling physics alltogether)?

This is possible as well :slight_smile:
Just call scene.getPhysicsEngine().setGravity(gravityVec3)

1 Like