Matter Physics - collision with vertices not allways correct

Hi there,

i’ve got a little problem with Matter physics and the usage of custom vertices for the body.

here is a jsfiddle to demonstrate the wired behavior (you will not be able to walk to each border of the building):
https://jsfiddle.net/ragesoft/bdhq54s9/

here is a screenshot to show you the problem in game:

on left side: the “collision area” by matter
on right side: the debug-borders from vertices

It seems like phaser / matter detects the new body borders correclty (blue borders in debug mode).
But i’m not able to get to them at all points of the object. it seems there is a invisible “wall” still added to the game object.

Someone can point me to the right settings?
How can i get a 100% correct collision with my custom vertices :slight_smile:
Thx a lot!

Greetings.

Your shape is concave. I think you need to decompose it.

I somehow managed it…
if i do it with “verts” and not the “PhysicsEditor” array of “x,y” coordinates it seems to work…

In this exmaple i created a polygone to check collision and also use the same set of points for a “normal” sprite in matter:
https://jsfiddle.net/ragesoft/h3one9jz/

the trick seems to be this lines of code:

shape: {
      	type: 'fromVerts',
        verts: polydata,
      },

:slight_smile:

That makes sense:

fromVertices(x, y, vertexSets [, options] [, flagInternal] [, removeCollinear] [, minimumArea])

Creates a body using the supplied vertices (or an array containing multiple sets of vertices) and adds it to the World. If the vertices are convex, they will pass through as supplied. Otherwise, if the vertices are concave, they will be decomposed. Note that this process is not guaranteed to support complex sets of vertices, e.g. ones with holes.

fromPhysicsEditor does not decompose.