I can't destroy joint. ;/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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) |
No, I just added minimized code :) 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.
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.
When I create a joint in if statement I cant maintain reference to the joint outside the statemant.
Take the local out from the joint - let me know if that helps :)
Looks like it works, thanks :)
Not a problem, good luck with the project :)
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?