-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
Description
Version
- Phaser Version: 3.60.0
- Operating system: MacOS Ventura 13.3
- Browser: Chrome 112.0.5615.49
Description
The boolean property ignoreGravity on matter MatterJS.BodyType is not working anymore since release 3.60.0.
Although it is set to true, the body is affected by gravity.
Example Test Code
export class Bullet extends Phaser.Physics.Matter.Sprite {
constructor(...) {
super(...);
...
this.setIgnoreGravity(true);
...
}
}
Additional Information
The evaluation of the flag is missing in method Engine._bodiesApplyGravity.
This should be the correct code for this method, as it was before.
Also without typos in the jsdoc :)
/**
* Applies a mass dependent force to all given bodies.
* @method _bodiesApplyGravity
* @private
* @param {body[]} bodies
* @param {vector} gravity
*/
Engine._bodiesApplyGravity = function(bodies, gravity) {
var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001,
bodiesLength = bodies.length;
if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) {
return;
}
for (var i = 0; i < bodiesLength; i++) {
var body = bodies[i];
if (body.ignoreGravity || body.isStatic || body.isSleeping){
continue;
}
// add the resultant force of gravity
body.force.y += body.mass * gravity.y * gravityScale;
body.force.x += body.mass * gravity.x * gravityScale;
}
};
johnedvardAstroCorp