Physics Problem going halfway through a wall?

Hey guys im currently working on a rapid prototype for a general idea and am having issues with physics engine. Whats happening is the ball will go halfway through the second platform but never all the way through?

Heres the code and keep in mind its not optimized or anything as its just prototyping. 

-- Include all the required external files local perspective = require("perspective") local physics = require("physics") -- Hide status bar display.setStatusBar(display.HiddenStatusBar) -- Setup camera local camera = perspective.createView() --Start Physics physics.start() physics.setGravity(0, 1) physics.setDrawMode("hybrid") -- Useful Variables \_H = display.contentHeight -- Make Display Objects local background = display.newImageRect("bg.jpg", 2000, 2000) local ball = display.newCircle(0, 0, 20) local floor1 = display.newRect(0, 0, 500, 40) local floor2 = display.newRect(0, 0, 1000, 10) -- Position Display Objects ball:setReferencePoint(display.CenterReferencePoint) ball.x, ball.y = 20, 20 floor1:setReferencePoint(display.CenterLeftReferencePoint) floor1.x, floor1.y = 0, 65 floor2:setReferencePoint(display.CenterLeftReferencePoint) floor2.x, floor2.y = 230, 200 floor2.rotation = -5 -- Add physics to all objects physics.addBody(ball, "dynamic", {radius = 20}) ball.isBullet = true physics.addBody(floor1, "static", {}) physics.addBody(floor2, "static", {}) -- Add Display Objects to camera camera:add(background, l, false) camera:add(ball, l, true) camera:add(floor1, l, false) camera:add(floor2, l, false) -- Start Camera Tracking camera:track() camera:setBounds(false) -- Add temp buttons for control local rButton = display.newRect(0,0,50,10) local lButton = display.newRect(0,0,50,10) -- Position buttons rButton:setReferencePoint(display.CenterReferencePoint) rButton.x, rButton.y = 130, \_H - 30 lButton:setReferencePoint(display.CenterReferencePoint) lButton.x, lButton.y = 40, \_H - 30 local function MoveBallR(event) -- Move the ball if event.phase == "began" then print("Move Right") ball:applyForce(1, 0, ball.x, ball.y) end end local function MoveBallL(event) -- Move the ball if event.phase == "began" then print("Move Left") ball:applyForce(-1, 0, ball.x, ball.y) end end rButton:addEventListener("touch", MoveBallR) lButton:addEventListener("touch", MoveBallL)

I am using the Perspective file found here

I have tryed isBullet, physics.setScale, iterrations, thickening the walls, and several other things that I have found all make zero difference in the actions.

Thanks for all the help in advanced!

Have you tried

physics.setContinuous(true)  

I’ve found setting it to false helps prevent joint stretching but does tend to cause unwanted tunneling.  Setting it to true might have the opposite effect.  I think true is the default so if you’re not setting it’s probably already on.  Try both and see if either has any effect.

Thanks for the help HardBoiledIndustries, however setting this to true does not fix the issue nor does setting it to false, i do appreciate you taking the time to help =P im stumped on this one, ive even set the gravity super low to make sure its not any type of velocity issue but still isnt working correctly. It goes ~80% through the floor and then stops lol

HeyTruIndieGames,

have you tried rotating the floor2 object after creating the physics body?  What does it look like when hybrid draw mode is on?

Hey R.delia,

Thanks for the reply the hybrid mode shows it is correctly oriented and i have tryed to rotate after adding physics body which didnt help = (

Thanks again for your time!

Hi @TruIndieGames,

You should avoid positioning and rotating physics bodies by a non-center reference point. It’s better to calculate the point based on center, then put the object there and rotate it. Without being able to see your actual scenario, I think the issue here is that your physics bodies are in a different place (in regards to the collision engine) than the hybrid view is showing. This is a common misunderstanding for beginners, but fortunately it’s easily fixable.

Best regards,

Brent Sorrentino

Thank you so much Brent! That fixed the problem completely, thanks for your time!

Have you tried

physics.setContinuous(true)  

I’ve found setting it to false helps prevent joint stretching but does tend to cause unwanted tunneling.  Setting it to true might have the opposite effect.  I think true is the default so if you’re not setting it’s probably already on.  Try both and see if either has any effect.

Thanks for the help HardBoiledIndustries, however setting this to true does not fix the issue nor does setting it to false, i do appreciate you taking the time to help =P im stumped on this one, ive even set the gravity super low to make sure its not any type of velocity issue but still isnt working correctly. It goes ~80% through the floor and then stops lol

HeyTruIndieGames,

have you tried rotating the floor2 object after creating the physics body?  What does it look like when hybrid draw mode is on?

Hey R.delia,

Thanks for the reply the hybrid mode shows it is correctly oriented and i have tryed to rotate after adding physics body which didnt help = (

Thanks again for your time!

Hi @TruIndieGames,

You should avoid positioning and rotating physics bodies by a non-center reference point. It’s better to calculate the point based on center, then put the object there and rotate it. Without being able to see your actual scenario, I think the issue here is that your physics bodies are in a different place (in regards to the collision engine) than the hybrid view is showing. This is a common misunderstanding for beginners, but fortunately it’s easily fixable.

Best regards,

Brent Sorrentino

Thank you so much Brent! That fixed the problem completely, thanks for your time!