Another strange physics question

If you make the two “paddles” touch each other, the first time they touch it works, but every subsequent time after that hey simply phase through each other.

displayMode( FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)

function setup()
    p1=physics.body(CIRCLE,30)
    p1.position = vec2(50,HEIGHT/2)
    p1.name = "paddle1"
    p1.gravityScale = 0
    p1.type = DYNAMIC
    p1.draw = function()
        pushStyle()
        noStroke()
        fill(255)
        ellipse(p1.x,p1.y,p1.radius*2)
        popStyle()
    end
    p2=physics.body(CIRCLE,30)
    p2.position = vec2(WIDTH-50,HEIGHT/2)
    p2.name = "paddle1"
    p2.gravityScale = 0
    p2.type = DYNAMIC
    p2.draw = function()
        pushStyle()
        noStroke()
        fill(255)
        ellipse(p2.x,p2.y,p2.radius*2)
        popStyle()
    end
end
function draw()
    background(0)
    p1:draw()
    p2:draw()
end
function touched(t)
    if t.state == BEGAN and p1.position:dist(vec2(t.x,t.y))<25 then
        touch1 = t
    elseif t.state == BEGAN and p2.position:dist(vec2(t.x,t.y))<25 then
        touch2 = t
    end
    if t.state == MOVING and touch1 and t.id == touch1.id then
        p1.position = vec2(t.x,t.y)
        if t.x > WIDTH/2 then
            p1.position.x = WIDTH/2
        end
    elseif t.state == MOVING and touch2 and t.id == touch2.id then
        p2.position = vec2(t.x,t.y)
        if t.x < WIDTH/2 then
            p2.position.x = WIDTH/2
        end
    end
end

set sleepingAlowed to false


    p1.sleepingAllowed=false

    p2.sleepingAllowed=false

why, please, dave?

@RonJeffries I don’t know the exact reason, it’s just from past experience I know that it works. I’m not sure what the purpose of allowing an object to sleep is. I guess I could google it, but I never had a reason to.

Thank you muchly @dave1707

I did a Google search for sleepingAllowed and found that when a body stops moving, it goes to sleep. That means that the physics engine doesn’t waste a lot of time doing any calculations on it. Supposedly if it is involved in a collision, it’s supposed to wake up and react. Apparently Codea doesn’t do that or something else isn’t being set.

Huh, strange. Thank you for the info, though!