phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Matter.js - Ignored Restitution on Static Bodies with Physics Configuration

Open monteiz opened this issue 6 months ago • 1 comments

Version

  • Phaser Version: 3.70

Description

When using Matter.js as the physics engine in Phaser 3.70, setting the restitution value for a static body seems to be ignored. The following code snippet exemplifies the issue:

peg.setCircle(peg.displayWidth / 2, {
    label: "peg",
    restitution: 15, // ignored
    friction: 0,
    frictionStatic: 0,
    isStatic: true,
});

peg.setBounce(2); // considered

Setting restitution: 15 directly on the static body doesn't seem to affect its behavior. Instead, using setBounce(2) seems to achieve the desired restitution effect. This behavior is unexpected when configuring a static body's restitution directly.

monteiz avatar Dec 21 '23 12:12 monteiz

Tested this in Matter.js without Phaser, as I noticed while testing it wasn't just a 3.70 issue.

When setting a body to static, restitution will be 0 even if set otherwise, with standalone Matter.js.

This should be solved upstream. Threw in the example with just Matter.js if you want to test. matterjs_test.txt

rgk avatar Jan 12 '24 18:01 rgk