How to change the gravity in Matter Js Engine
Posted on January 25, 2023
Here the way to change the gravity value at runtime in a Matter.js engine instance:
// suppose this engine
var engine = Engine.create()
// engine.gravity contains the default gravity value
/*
gravity: {
x: 0,
y: 1,
scale: 0.001
},
*/
// change it at runtime:
engine.gravity.y = 0.3
Learned from the source code here.