Hi Horacebury,
My code here :
function player:controlPhysics(action) if action == "create" then print("createPhysics") self.physics = display.newRect(self.gameGroup, 0, 0, 40, 40 ) self.physics:setFillColor(0, 0, 1, 0.7) self.physics.x = self.x self.physics.y = self.y self.physics.id = "main\_physics" local bodyW = ( self.physics.width\*.5 ) local bodyH = ( self.physics.height\*.5 ) local body = { -bodyW, -bodyH, bodyW, -bodyH, bodyW, bodyH, -bodyW, bodyH } physics.addBody( self.physics, "dynamic", {density = 100, friction = 0.3, bounce = 0, shape = body} ) self.physics.isVisible = false self.physics.setAsSensor = false self.physics.isSleepingAllowed = false self.physics.isFixedRotation = true self.physics.isBullet = true self.safe\_physics = display.newRect(self.gameGroup, 0, 0, 40, 5 ) self.safe\_physics:setFillColor(0, 1, 0, 0.7) self.safe\_physics.x = self.x self.safe\_physics.y = self.physics.y + self.physics.height\*.5 + self.safe\_physics.height\*.5 self.safe\_physics.id = "safe\_physics" local bodyW = ( self.safe\_physics.width \*.5 ) local bodyH = ( self.safe\_physics.height \*.5 ) local body = { -bodyW, -bodyH, bodyW, -bodyH, bodyW, bodyH, -bodyW, bodyH } physics.addBody( self.safe\_physics, "dynamic", {density = 100, friction = 0.3, bounce = 0, shape = body} ) self.safe\_physics.isVisible = true self.safe\_physics.isSensor = true self.safe\_physics.setAsSensor = true self.safe\_physics.isSleepingAllowed = false self.safe\_physics.isBullet = true self.weldJoint = physics.newJoint( "weld", self.physics, self.safe\_physics, self.physics.x, self.physics.y ) elseif action == "destroy" then display.remove(self.physics) self.physics = nil display.remove(self.safe\_physics) self.safe\_physics = nil display.remove(self.weldJoint) self.weldJoint = nil end end
But the thing is I try this code on a new project and it works, so it’s something on my current project making the trouble but I try to manage a lot of stuff but still same thing, I’m not able to figure out where the problem occurs, the link for the joint is not at the right place and moving quicker than the objects but the joint works both object are moving together…
I post in case if someone have already encoutering this problem otherwise I know it’s hard to say without the whole code