Collision not working on Ceiling & Floor

Hi all the other Collision are borking but not the Ceiling & Floor is there something wrong in my code ? 

    ceiling = display.newImage(“invisibleTile.png”)

    ceiling:setReferencePoint(display.BottomLeftReferencePoint)

    ceiling.x = 0

    ceiling.y = -20

    physics.addBody(ceiling, “static”, {density=.1, bounce=0.1, friction=.2})

    ceiling.name = “theCeiling”

    

    theFloor = display.newImage(“invisibleTile.png”)

    theFloor:setReferencePoint(display.BottomLeftReferencePoint)

    theFloor.x = 0

    theFloor.y = 500

    physics.addBody(theFloor, “static”, {density=.1, bounce=0.1, friction=.2})

    ceiling.name = “theFloor”

local function onCollision(event)

    if event.phase == “began” and gameIsActive == true then

        local obj1 = event.object1; 

        local obj2 = event.object2; 

        

           if obj1.name == “jetplayer” then

        if     obj2.name == “BCloud1” then MinLife()

        elseif obj2.name == “BCloud2” then pontsMin10()

        elseif obj2.name == “BCloud3” then pontsMin20()

        elseif obj2.name == “GCloud1” then pontsplus50()

        elseif obj2.name == “theFloor” then explode()

        elseif obj2.name == “theCeiling” then explode()

        end

    end

    

Hi Kevin,

Quite possibly it’s because you’re positioning them based on non-center reference points. Physics objects don’t like to be shifted around using non-center origins. Please try to position your objects based on the center point and see if that solves the issue.

Brent

HI Brent i have removed the “ceiling:setReferencePoint(display.BottomLeftReferencePoint)” & “theFloor:setReferencePoint(display.BottomLeftReferencePoint)” but no change 

Hi Kevin,

What “type” of bodies are you trying to sense collision with on your floor and ceiling? Dynamic or kinematic?

Brent

Hi Kevin,

Quite possibly it’s because you’re positioning them based on non-center reference points. Physics objects don’t like to be shifted around using non-center origins. Please try to position your objects based on the center point and see if that solves the issue.

Brent

HI Brent i have removed the “ceiling:setReferencePoint(display.BottomLeftReferencePoint)” & “theFloor:setReferencePoint(display.BottomLeftReferencePoint)” but no change 

Hi Kevin,

What “type” of bodies are you trying to sense collision with on your floor and ceiling? Dynamic or kinematic?

Brent