Is there any way to disable gravity in Matter.js? I want my objects (bodies) to keep their physical abilities (like reaction to collision, restitution, friction etc), but I'd like to prevent the reaction to device's gyro and orientation change.
Try
engine.world.gravity.y = 0;
where engine
is your engine instance.
You just need to add this to your config:
physics: {
default: "matter",
matter: {
gravity: {x: 0, y: 0},
// ^^^^^^^^^^^^^^^^^^^
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With