Trying to implement an axel joint and because the wheel joint does not provide the same limits and motor that the piston joint does I’m doing this with a pivot and a piston.
The two objects to be joined are connected via a middle object (the axel) and, unlike other joint types, this does not stop the two objects from colliding. This means that they need a collision filter or they will jitter all over the place.
Finally, because the two objects to be joined are joined via a third (the axel) the composite joint is now squishy.
Can anyone improve on this?
require("physics") physics.start() physics.setGravity( 0, 10 ) physics.setDrawMode("hybrid") local a = display.newRect( 400, 400, 800, 50 ) a.rotation = -35 local b = display.newRect( 600, 350, 50, 300 ) b.fill = {.5,.5,.5} physics.addBody(a,"static",{isSensor=false,density=.1, filter={ groupIndex=-1 }}) physics.addBody(b,"dynamic",{isSensor=false,density=.1, filter={ groupIndex=-1 }}) local ax, ay = a:localToContent( -400, 0 ) local bx, by = a:localToContent( 400, 0 ) local cx, cy = b:localToContent( 0, -150 ) local dx, dy = b:localToContent( 0, 150 ) local d = display.newGroup() d.x, d.y = 600, 260 physics.addBody( d, "dynamic", { radius=40, isSensor=true } ) local j = physics.newJoint( "piston", a, d, 600, 260, bx-a.x, by-a.y ) j.isLimitEnabled = true j:setLimits( -600, 200 ) local p = physics.newJoint( "pivot", d, b, 600, 260 )