I started out with a MatterJs image and a call to setCircle. Then I had a setOnCollideWith to handle the collision with another object. This worked fine.
this.image = this.scene.matter.add.image(x, y, ‘assets’, ‘peg_normal’);
this.image.setCircle(this.image.width/2, { isStatic: true, friction: 0 });
this.image.setOnCollideWith(this.scene.ball.image, () => {
this.hitPeg();
});
Next, I created a physics shape with PhysicsEditor by CodeAndWeb.
"peg": {
"type": "fromPhysicsEditor",
"label": "peg",
"isStatic": true,
"density": 0.1,
"restitution": 0.9,
"friction": 0,
"frictionAir": 0.009999999776482582,
"frictionStatic": 0.5,
"collisionFilter": {
"group": 0,
"category": 2,
"mask": 1
},
"fixtures": [
{
"label": "",
"isSensor": false,
"circle": {
"x": 18.977272727272727,
"y": 18.90909090909091,
"radius": 15
}
}
]
}
Then I updated my code to set the shape on my image.
let pegsmatter = this.scene.cache.json.get(‘pegsmatter’);
this.image = this.scene.matter.add.image(x, y, ‘assets’, ‘peg_normal’, { shape: pegsmatter.peg } as any);
The collider seems to be in the right place, but the collision physics changed significantly (No bounce even thought I set the restitution really high) and setOnCollideWith no longer fires.
Any thoughts?