Joint working but moving quicker than objects

Hi,

I’m trying to apply a weld joint to keep two body together, everything is working but when I look the physics debug mode, I can’t see my joint (the blue line) but when I start the game I’m applying a velocity to the player and there I can see my joint going from the left and going quicker than both objects it should be attach.

I tried this code on new sample and this is working normaly … I don’t success to find out what in my game is acting like that for ?

The thing is the joint work as it should, my two body are attached and move together but the joint is not beetween them but far away 

Any idea would be appreciate, I can post my sample if you need.

Thanks in advance

Without seeing the code it’s hard to answer your question, but one thing might be that the joint is simply not where you think it is.

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

Hmm. Boil the code with the problem down to remove parts without problems until you’re left with just the problem code.

Ok found it, it comes from my camera :

 self.gameGroup.x = -player.physics.x + self.xGame

Do you think that matters for the collision involded in my game ?

box2D and corona physics make myself sick, one problem solve an other blow up   :blink:

Without seeing the code it’s hard to answer your question, but one thing might be that the joint is simply not where you think it is.

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

Hmm. Boil the code with the problem down to remove parts without problems until you’re left with just the problem code.

Ok found it, it comes from my camera :

 self.gameGroup.x = -player.physics.x + self.xGame

Do you think that matters for the collision involded in my game ?

box2D and corona physics make myself sick, one problem solve an other blow up   :blink: