I took quite a while trying to track down a physics issue. I noted in the end the shape was not perfectly convex, but the issue was physics.setDrawMode not showing true physics boundary if shape is not perfectly convex.
Logged a bug to cover this, although not sure if this would be treated as bug?
I think there should be:
(a) Minimum - some warning/error to developers at the minimum to highlight the fact they have “shape” they have used which will not work. This will save hours of unnecessary effort for developers trying to track down issues.
(b) Best Case - Show true physics area in “setDrawMode” which is what a developer expects. So if the area is concave then the setDrawMode would show a convex shape instead, showing the shape that the physics engine is really going to use.
-- Version 2013.1178 (2013.8.2) local physics = require( "physics" ) physics.start() physics.setGravity(0, 1) physics.setDrawMode( "hybrid" ) -- SETUP OBJECTS local crate2 = display.newRect(0,0,60,60) crate2.x = 180; crate2.y = 300 crate2.myName = "second crate" local myRectangle = display.newRect(180, 150, 90,90) myRectangle.strokeWidth = 1 myRectangle:setFillColor(0, 0, 200, 100) myRectangle:setStrokeColor(0, 200, 0, 0) myRectangle.rotation = 90 physics.addBody( myRectangle, "dynamic", { fdensity=3.0, friction=0.5, bounce=0.3, shape={ -40,-36, 40,-36, 20,0 , 6,36, -6,36, -20, 0 } } ) myRectangle.gravityScale = 0.2 myRectangle:addEventListener( "collision", function(event) myRectangle:setFillColor(200, 0, 0) end ) physics.addBody( crate2, "static", { density=3.0, friction=0.5, bounce=0.3 } )