joint remove problem

I can’t destroy joint. ;/

[code]playerRotation = function()
if(press)then
player.bodyType = ‘dinamic’
myJoint:removeSelf()
end
if(hit)then
player.bodyType = ‘kinetic’
myJoint = physics.newJoint( “pivot”, player, objektas, player.x, player.y )
end

end

Runtime:addEventListener( “enterFrame”, playerRotation )

local function onCollision( event )
hit = true
end

Runtime:addEventListener ( “collision”, onCollision )

function onTouch( event )
press = true
return true
end

background:addEventListener( “touch”, onTouch)
[import]uid: 123082 topic_id: 21566 reply_id: 321566[/import]

It looks like you are trying to destroy the joint above where it is created in the code; do you create the joint further up then recreate it again, or no? [import]uid: 52491 topic_id: 21566 reply_id: 85763[/import]

No, I just added minimized code :slight_smile: An object falls on a wheel and makes a joint to spin together and after a touch the joint should be destoyed, but it returns nil. I think i cant maintain the a reference to the joint. [import]uid: 123082 topic_id: 21566 reply_id: 85793[/import]

local myJoint = physics.newJoint( “pivot”, player, objektas, player.x, player.y )

when i make a joint outside of function(on start) it works well (destroy on tap), but then after a collision it makes a new joint with same name and that does not work. [import]uid: 123082 topic_id: 21566 reply_id: 85830[/import]

When I create a joint in if statement I cant maintain reference to the joint outside the statemant. [import]uid: 123082 topic_id: 21566 reply_id: 86821[/import]

Take the local out from the joint - let me know if that helps :slight_smile: [import]uid: 52491 topic_id: 21566 reply_id: 86864[/import]

Looks like it works, thanks :slight_smile:
[import]uid: 123082 topic_id: 21566 reply_id: 86869[/import]

Not a problem, good luck with the project :slight_smile: [import]uid: 52491 topic_id: 21566 reply_id: 86970[/import]