Matter.js: after call setVertices on body his collisions are not updated

Viewed 38

I use matter.js physic engine for my game. I updated body vertices with call setVertices but after call his collisions are not updated, so other object does not fall. Maybe I skipped some basic principles of using matter.js so I present short version of using them, if this is not enough I will create a separate working example.

// Init engine
const engine = Engine.create();
const runner = Runner.create();
Runner.run(runner, engine);

// Add circle for check collision
const circle = Bodies.polygon(300, 100, 5, 12, {
    frictionAir: 0, friction: 0.0001, restitution: 0.6
});
World.add(engine.world, circle);

// Create a body from vertex (parsed from svg path)
// Original vertexes
const mapVertexes = [[..]];
const ground = Bodies.fromVertices(400, 400, mapVertexes, { isStatic: true }, true);
World.add(engine.world, ground);

// On click to update vertices for polygon
const newVertices = [...]
Body.setVertices(ground, newVertices);

Before update vertices:

enter image description here

After update vertices:

enter image description here

0 Answers
Related