"Hollow" physic shape instead of "Full" physic shape

Hey there !

I’m having a little bit of trouble with my polygonal physics objects.

I’ve got a newPolygon object, which is created like that :

local customShape = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 } local pentagon = display.newPolygon(0,0, customShape) physics.addBody( pentagon, "static",{ shape=pentagonShape, density=3.0, friction=0.8, bounce=0.3 } )

Unfortunatly, it seems to create a “hollow” object : if a small object gets in collision with it, there’s a chance it gets through it and gets trapped inside of it. In the hybrid view, it gives me something like that :

RZSq6Q1.png

So, the first shape is my pentagon. The second shape is a triangle, but instead of using newPolygon, I’m loading a picture (or creating a circle, both work) and applying a custom shape as a physic shape. As you can see, the triangle is “full” while the pentagon is “hollow”.

local triangle = display.newRect(0,0,100,300) local triangleShape = { 0,-35, 37,30, -37,30 } physics.addBody( triangle, "static", { shape=triangleShape, density=1.6, friction=0.5, bounce=0.2 } )

Is it possible to create a newPolygon, using its coordinates and then applying it as a physic shape so that it gets “full” ?

Ok my bad, I simply used the wrong shape coordinates… It works fine now !

@evanspro,

Please post your corrected code so folks can see how you fixed the problem.  Don’t forget.  Getting help in the forums is about getting answers to your questions AND helping others with the same or similar issues in the future.  People will benefit from seeing the problem and the solution in on place.

his shape looks fine, probably just named wrong in addBody (“pentagonShape” doesn’t exist, “customShape” does)

I understand, but the fact is that I already said what was wrong :slight_smile: But if needed, the right code is :

local customShape = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 } local pentagon = display.newPolygon(0,0, customShape) physics.addBody( pentagon, "static",{ shape=customShape , density=3.0, friction=0.8, bounce=0.3 } ) local triangle = display.newRect(0,0,100,300) local triangleShape = { 0,-35, 37,30, -37,30 } physics.addBody( triangle, "static", { shape=triangleShape, density=1.6, friction=0.5, bounce=0.2 } )

Ok my bad, I simply used the wrong shape coordinates… It works fine now !

@evanspro,

Please post your corrected code so folks can see how you fixed the problem.  Don’t forget.  Getting help in the forums is about getting answers to your questions AND helping others with the same or similar issues in the future.  People will benefit from seeing the problem and the solution in on place.

his shape looks fine, probably just named wrong in addBody (“pentagonShape” doesn’t exist, “customShape” does)

I understand, but the fact is that I already said what was wrong :slight_smile: But if needed, the right code is :

local customShape = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 } local pentagon = display.newPolygon(0,0, customShape) physics.addBody( pentagon, "static",{ shape=customShape , density=3.0, friction=0.8, bounce=0.3 } ) local triangle = display.newRect(0,0,100,300) local triangleShape = { 0,-35, 37,30, -37,30 } physics.addBody( triangle, "static", { shape=triangleShape, density=1.6, friction=0.5, bounce=0.2 } )