Limitation on body shapes / multi-element bodies

Is there a limit to the number of elements which can be added to a multi-element body?

I am noticing an offset of some body elements when I have >5.

Having looked into the documentation, it may appear as though I’ve not read deeply enough into the implications.

Given this quote, “When creating multi-element bodies, each element must be specified as a separate polygonal shape.” from here:

https://docs.coronalabs.com/guide/physics/physicsBodies/index.html#multi-element-bodies

I would like to know if this is implying that different body elements cannot be reliably used together, for example can you construct a body using all of the following at the same time:

For example, I think introducing a rectangular (‘box’) shape into a multi-element body causes problems, unless it’s done last. The following code should produce the same shaped bodies, but the second has a strange offset to one of the elements:

local physics = require("physics") physics.start() physics.setGravity(0,0) physics.setDrawMode("hybrid") local a = display.newGroup() a.x, a.y = 200, 200 physics.addBody( a, "static", { shape={ 100, 100, 200, 100, 200, 200, 100, 200 } }, { box={ x=250, y=150, halfWidth=50, halfHeight=50, angle=0 } } ) local b = display.newGroup() b.x, b.y = 200, 400 physics.addBody( b, "static", { box={ x=250, y=150, halfWidth=50, halfHeight=50, angle=0 } }, { shape={ 100, 100, 200, 100, 200, 200, 100, 200 } } )

Let me see what I can find out for you.

Rob

@horacebury, can you put that in a .zip file with a config.lua and build.settings and use the Report a bug link at the top of the page?  This doesn’t sound familiar to our engineers, so we will need to take a deeper dive into it.

But at least for now, it seems you have a potential work around.

Rob

Yes, in short the bug appears when different types of shape (shape, box, outline, etc) are used when defining a single body. If only one type is used the problem goes away (…at least for the case of ‘shape’, which is the only one I’ve tried.)

I guess this why tools like PhysicsEditor don’t cause problems because they are almost always multi-polygon shaped bodies.  Anyway thanks for submitting the bug report, as a reference, here is the case ID 13247833.

Rob

Having looked into the documentation, it may appear as though I’ve not read deeply enough into the implications.

Given this quote, “When creating multi-element bodies, each element must be specified as a separate polygonal shape.” from here:

https://docs.coronalabs.com/guide/physics/physicsBodies/index.html#multi-element-bodies

I would like to know if this is implying that different body elements cannot be reliably used together, for example can you construct a body using all of the following at the same time:

For example, I think introducing a rectangular (‘box’) shape into a multi-element body causes problems, unless it’s done last. The following code should produce the same shaped bodies, but the second has a strange offset to one of the elements:

local physics = require("physics") physics.start() physics.setGravity(0,0) physics.setDrawMode("hybrid") local a = display.newGroup() a.x, a.y = 200, 200 physics.addBody( a, "static", { shape={ 100, 100, 200, 100, 200, 200, 100, 200 } }, { box={ x=250, y=150, halfWidth=50, halfHeight=50, angle=0 } } ) local b = display.newGroup() b.x, b.y = 200, 400 physics.addBody( b, "static", { box={ x=250, y=150, halfWidth=50, halfHeight=50, angle=0 } }, { shape={ 100, 100, 200, 100, 200, 200, 100, 200 } } )

Let me see what I can find out for you.

Rob

@horacebury, can you put that in a .zip file with a config.lua and build.settings and use the Report a bug link at the top of the page?  This doesn’t sound familiar to our engineers, so we will need to take a deeper dive into it.

But at least for now, it seems you have a potential work around.

Rob

Yes, in short the bug appears when different types of shape (shape, box, outline, etc) are used when defining a single body. If only one type is used the problem goes away (…at least for the case of ‘shape’, which is the only one I’ve tried.)

I guess this why tools like PhysicsEditor don’t cause problems because they are almost always multi-polygon shaped bodies.  Anyway thanks for submitting the bug report, as a reference, here is the case ID 13247833.

Rob