liabru / matter-js

a 2D rigid body physics engine for the web ▲● ■
MIT License
16.62k stars 1.96k forks source link

Simple Polygon Physics Issues #1276

Open Calcue-dev opened 7 months ago

Calcue-dev commented 7 months ago

In my game, I have a scenario where (simple) polygons are created dynamically in parts from vertices.

However, I am facing what appears to be a bug with the physics between these Polygons.

Take the below image of 2 polygons (showing vertices ordering via numbers).

polys

I have recreated this example that shows a Polygon in two parts but when they collide together the behaviour is extremely strange, see the video below.

poly-issue.webm

As you can see above, once the two polygons collide one is strangely thrown around.

Does anyone know what might be going on here? This is just one example but I have other polygons also facing the issue.

See below for a codepen recreation including all vertices used etc (using phaser + matter) and some additional information embedded in the pen.

Codepen Recreation

Calcue-dev commented 7 months ago

Here is a more basic concave split in two halves with slowed speed and debug stats printing on the canvas. Need full screen to see all details. Codepen Example 2