Problems with unstable prismatic joint

What it is supposed to do:
several visualBodies created in the same horizontal line, must move along this common horizontal line to the right when gravity.x grows and make a stack one close to the next without overlap.

What happens:
when a bodiy moves right it first stacks then, after 3 seconds it pusshes body at its right. Looks like a force grows and forces bodies.

I worked for hours and tried lot of alternatives, unsuccessfully.

Thanks for help anybody.


Here is my code:

function Cell:newVisualBody(x,y) -- x, y = cell position
    visualBody = physics.body(POLYGON,
    visualBody.gravityScale= 100
    visualBody.mass = 0.01
    visualBody.categories = {5}
    visualBody.mask = {5}     -- collide with same bodies
    visualBody.position = vec2(x,y)
    sliderJoint = physics.joint(PRISMATIC, self.body, visualBody
                                 , self.body.position, vec2(1,0))
    sliderJoint.enableLimit = true
    sliderJoint.upperLimit = 50
    sliderJoint.lowerLimit = 1
    sliderJoint.enableMotor = true
    sliderJoint.maxMotorForce = 0
    return visualBody                       
end -- function newVisualBody()

Codea uses Box2D for physics, which itself uses an iterative constraint solver. When several joint constraints interact you can sometimes get unstable behaviour like this. I would recommend not setting gravityScale to values greater than 1 as this can cause instability. Also you don’t need to enable the motor. You could also try increasing the number of iterations the physics engine uses:

function setup()


Sorry John, it took me a long time to find that the issue was in a Codea bug whith
So that each new joint saved in .info whas erased by the next one.

Thanks for your help.