# Matter Physics - collision with vertices not allways correct

**URL:** <https://phaser.discourse.group/t/matter-physics-collision-with-vertices-not-allways-correct/9711>\
**Category:** Phaser 3\
**Created:** [June 2, 2021, 12:08pm UTC](https://phaser.discourse.group/t/matter-physics-collision-with-vertices-not-allways-correct/9711 "2021-06-02T12:08:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Puccini](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/puccini/32/4984_2.png) [@Puccini](https://phaser.discourse.group/u/Puccini)\
**Post date:** [June 2, 2021, 12:08pm UTC](https://phaser.discourse.group/t/matter-physics-collision-with-vertices-not-allways-correct/9711/1 "2021-06-02T12:08:50Z")

</div>

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/](https://jsfiddle.net/ragesoft/bdhq54s9/)

here is a screenshot to show you the problem in game:  
[![](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/b/ba6b243012245b365430ee986af3bb978077c7dc.png)](https://ibb.co/4VckCDC)  
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 🙂  
Thx a lot!

Greetings.

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [June 2, 2021, 1:38pm UTC](https://phaser.discourse.group/t/matter-physics-collision-with-vertices-not-allways-correct/9711/2 "2021-06-02T13:38:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Puccini](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/puccini/32/4984_2.png) [@Puccini](https://phaser.discourse.group/u/Puccini)\
**Post date:** [June 3, 2021, 5:51am UTC](https://phaser.discourse.group/t/matter-physics-collision-with-vertices-not-allways-correct/9711/3 "2021-06-03T05:51:07Z")

</div>

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/](https://jsfiddle.net/ragesoft/h3one9jz/)

the trick seems to be this lines of code:

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

```

🙂

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [June 3, 2021, 6:10am UTC](https://phaser.discourse.group/t/matter-physics-collision-with-vertices-not-allways-correct/9711/4 "2021-06-03T06:10:40Z")

</div>

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.
