Piston/Prismatic Joint not working on single axis.

This is definitely a show stopper for me so I’ll post it here. I can’t get the piston joint to constrain to a single axis like it is supposed to.

Here is a link to a working Piston joint in AS3 with box2d.

http://www.emanueleferonato.com/2009/02/03/box2d-joints-prismatic-joints/

I may be doing something wrong but I’ve been trying for weeks and can’t get it to work. Here is some sample code. You can pick up the big box and push the medium box off the y axis which it is supposed to be restricted too.

[code]
local physics = require(“physics”)
physics.start()
physics.setDrawMode(“debug”)

display.setStatusBar( display.HiddenStatusBar )

local function startDrag( event )
local t = event.target

local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true

t.x0 = event.x - t.x
t.y0 = event.y - t.y

event.target.bodyType = “kinematic”

event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0

elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0

elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
event.target.bodyType = “dynamic”

end
end

return true
end

local bigBlock = display.newRect( 0, 0, 128, 128 )
bigBlock.x = 160; bigBlock.y = 0
physics.addBody( bigBlock, { density=5.0, friction=0.4, bounce=0.2 } )

local anchor = display.newRect( 0, 0, 32, 32 )
anchor.x = 160; anchor.y = 400
physics.addBody( anchor, “static” )

local block = display.newRect( 0, 0, 64, 64 )
block.x = 160; block.y = 300
physics.addBody( block, { density=3.0, friction=0.4, bounce=0.2 } )

bigBlock:addEventListener( “touch”, startDrag )
block:addEventListener( “touch”, startDrag )

myJoint = physics.newJoint( “piston”, block, anchor, anchor.x, anchor.y, 0,5 )
myJoint.isLimitEnabled = true
myJoint:setLimits(1,1)
[/code] [import]uid: 10243 topic_id: 6007 reply_id: 306007[/import]

Is it a bug? Am I doing something wrong? If it is a bug, are you going to fix it? If it’s something I’m doing wrong, please tell me how to fix it. If this is a bug or an issue that is not going to be resolved, just let me know and I’ll continue learning other frameworks/engines. [import]uid: 10243 topic_id: 6007 reply_id: 21185[/import]

Hi,

Thanks for the report. It is a bug that we’ve fixed internally (case 3302) and will be available in the next release.

Tim [import]uid: 8196 topic_id: 6007 reply_id: 21227[/import]

Great, thanks so much. I believe the wheel/line joint had the same problem as this joint just in case you didn’t look at that one too.

Wow, it was a bug, I guess I’m not crazy after all. I spent weeks trying to figure out what I was doing wrong. I appreciate you guys addressing and correcting this issue. [import]uid: 10243 topic_id: 6007 reply_id: 21315[/import]

Was this bug fix added to any of the daily builds? Thanks! [import]uid: 3046 topic_id: 6007 reply_id: 30626[/import]