Collision detection on a physics object not working.

Hi guys. This is only my 3rd day of using Corona and love it, however I’ve run into an issue.

I’m trying to create a complex physics object, however, for some reason whenever the player walks over it, about half way through they fall through…

Now I’m thinking its due to how I entered the coordinates (clockwise notation), but I’ve tried changing them around and doing them backwards but no luck. Its just a rectangle, so, it shouldn’t have any concave issues. Any tips?

[code]
–add the ground
local ground1 = display.newImage(“ground1.png”)
game:insert(ground1)
local physics_body = {}
physics_body[“ground1”] = {

{
density = 5.0, friction = 0.5, bounce = 0.3,
shape = {400,200, 400,220, 0,220, 0,200}
}
}

physics.addBody(game, “static”, unpack(physics_body[“ground1”]))
[/code] [import]uid: 81846 topic_id: 14421 reply_id: 314421[/import]

First, turn on physics debug:
physics.setDrawMode( “debug” )

Then, I believe you need to define your shape boundry “from the centroid of the object”.
[import]uid: 21331 topic_id: 14421 reply_id: 53378[/import]

Oh, yes I have all that.

-- Activate physics engine  
local physics = require("physics")  
physics.start()  
physics.setGravity(0.3,9.8)  
physics.setDrawMode("hybrid")  

If i just do;
physics.addBody(ground1,{ density=2.0, friction=0.5, bounce=0.3})

And dont determine the shape, then it works fine.

Also, what do you mean by define the shape boundary from the centroid of the object? Something like, the points are dependent on the centre of the object?
[import]uid: 81846 topic_id: 14421 reply_id: 53380[/import]

Correct. This is one of the early issues I ran into. Box2d engine evidentally assumes all objects have a center reference point. So a box 100 width and height will be defined as -50, -50 and 50, 50. Give that a go. [import]uid: 21331 topic_id: 14421 reply_id: 53387[/import]