Because static bodies have infinite mass and other propeties, after setting at least 1 body to static this results with completely bugged stage (bodies get infinite prop.)
Actually there should be possibility to add gravity force for static bodies - is it required for body to has infinity?
Anyway I think quick fix like this would be nice anyway because everything just stops working at the moment.
gravity: function(bodyA, bodyB) {
// apply force only if both bodies are not static
if(!bodyA.isStatic && !bodyB.isStatic){
// use Newton's law of gravitation
var bToA = Matter.Vector.sub(bodyB.position, bodyA.position),
distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001,
normal = Matter.Vector.normalise(bToA),
magnitude = -MatterAttractors.Attractors.gravityConstant * (bodyA.mass * bodyB.mass / distanceSq),
force = Matter.Vector.mult(normal, magnitude);
// to apply forces to both bodies
Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force));
Matter.Body.applyForce(bodyB, bodyB.position, force);
}
}
Because static bodies have infinite mass and other propeties, after setting at least 1 body to static this results with completely bugged stage (bodies get infinite prop.)
Actually there should be possibility to add gravity force for static bodies - is it required for body to has infinity? Anyway I think quick fix like this would be nice anyway because everything just stops working at the moment.