I’m having an issue with physics bodies falling through each other. I’m using a device tilt code that I found to move an object named inf around. When inf strikes either wall object the inf body looks like it sticks into the wall, and if you keep tilting the device it eventually falls through.
Is there any solution to this or is this an issue with the box 2d physics?
[code]
display.setStatusBar( display.HiddenStatusBar )
local physics = require(“physics”)
physics.start()
physics.setGravity( 0, 0)
physics.setDrawMode( “hybrid” )
local inf = display.newCircle( 320, 480, 25 )
physics.addBody( inf, { density = 1, bounce = 3, radius = 30 } )
local wall = display.newRect( 200, 200, 200, 50 )
physics.addBody( wall, “static”, { w = 200, h = 50, density = 3, bounce = 1 } )
local walltwo = display.newRect( 200, 0, 50, 200 )
physics.addBody( walltwo, “static”, { w = 50, h = 200, density = 3, bounce = 1 } )
local motionx = 0
local motiony = 0
local function onAccelerate(event)
motionx = 45 * event.xGravity
motiony = 45 * event.yGravity
end
Runtime:addEventListener( “accelerometer”, onAccelerate )
local function moveinf(event)
inf.x = inf.x + motionx
inf.y = inf.y - motiony
if inf.x < 0 then
inf.x = 0
elseif inf.x > 640 then
inf.x = 640
end
if inf.y < 0 then
inf.y = 0
elseif inf.y > 960 then
inf.y = 960
end
end
Runtime:addEventListener( “enterFrame”, moveinf )
[/code] [import]uid: 10903 topic_id: 13511 reply_id: 313511[/import]