Joints don't move (x,y) with display group (physics bodies contained in a group)

Hi, has anyone run into a workaround for this issue? I’ve submitted an offcial bug report but thought I’d throw it out there in case others have had the same problem.

The problem occurs when you:

  1. Make two physics bodies and connect them via pivot joints (haven’t tried all joint types)
  2. Add them to a display group.
  3. Move the X,Y coords of the display group ( helps visually to turn on 'physics.setDrawMode( “hybrid” ) ')

The joints do not move relative to the physics bodies and seem to be locked down to the original 0,0 display coords!

Example code follows, thanks! To see it work properly comment out this line:
[lua]transition.to( world, { time=2000, y=ragdoll.y-200, transition=easing.inOutExpo } )[/lua]

[lua]–> Setup Display
display.setStatusBar (display.HiddenStatusBar)

system.activate (“multitouch”)

local gameUI = require(“gameUI”)

–> Start Physics
local physics = require (“physics”)

physics.start ()
physics.setGravity (0, 10)
physics.setDrawMode (“hybrid”)

local world = display.newGroup()

– Make walls

local walls = display.newGroup()

local leftWall = display.newRect (0, 0, 1, display.contentHeight)
local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight)
local ceiling = display.newRect (0, 0, display.contentWidth, 1)
local floor = display.newRect (0, display.contentHeight, display.contentWidth, 1)

physics.addBody (leftWall, “static”, {bounce = 0.0, friction = 10})
physics.addBody (rightWall, “static”, {bounce = 0.0, friction = 10})
physics.addBody (ceiling, “static”, {bounce = 0.0, friction = 10})
physics.addBody (floor, “static”, {bounce = 0.0, friction = 10})

walls:insert(leftWall)
walls:insert(rightWall)
walls:insert(ceiling)
walls:insert(floor)
– Make our bodies
local originX = 100
local originY = 200
local ragdoll = display.newGroup ()

local head = display.newCircle( 0, 0, 8 )
head.x = originX
head.y = originY
head:setFillColor (255, 255, 255, 128)
ragdoll:insert (head)

local torso = display.newCircle( 0, 0, 15 )
torso.x = originX
torso.y = head.y + head.height
torso:setFillColor (255, 255, 255, 128)
ragdoll:insert (torso)
physics.addBody (head, {bounce = 0.0, friction = 1.0})
physics.addBody (torso, {bounce = 0.0, friction = 1.0})

function ragdoll:addFrictionJoint(a, b, posX, posY, rFrom, rTo, mT)
local j = physics.newJoint (“pivot”, a, b, posX, posY, rFrom, rTo)
j.isLimitEnabled = true
j:setRotationLimits (rFrom, rTo)
j.isMotorEnabled = true
j.motorSpeed = 0
j.maxMotorTorque = mT or .05
return j
end

– head
ragdoll:addFrictionJoint(head, torso, torso.x, torso.y, -2, 2, 0.1)

– torso
–ragdoll:addFrictionJoint(torso, head, head.x, torso.y-5, -4, 4, 0.5)

function ragdoll:touch( event )
gameUI.dragBody( event )
end

head:addEventListener ( “touch”, ragdoll )
torso:addEventListener ( “touch”, ragdoll )
world:insert(walls)
world:insert(ragdoll)

transition.to( world, { time=2000, y=ragdoll.y-200, transition=easing.inOutExpo } )[/lua]

[import]uid: 11507 topic_id: 13571 reply_id: 313571[/import]

I noticed this too but in my case at least it seems it’s just the visual representation of the joints in hybrid mode. I see no effect on the actual joints when scrolling in normal mode. Are you seeing effects to the physics? [import]uid: 40137 topic_id: 13571 reply_id: 58181[/import]

Yes, using the code I’ve posted you should see the physics error when dragging the ragdoll. It appears as a swinging pendulum effect, because the drag point is referenced relative to the position of the joint skeleton not the graphics.

I’ve made a download available for testing here
As far as I can tell this is still a bug as of Corona Version 2011.591 (2011.8.2) [import]uid: 11507 topic_id: 13571 reply_id: 58183[/import]

Ah, sorry. I see what you mean.

I added a second head to the ragdoll after the transition and its pivot joint showed up at the bottom with the original. I gave them all a density of 50 and changed the touch event from drag to linear impulse and the joints seemed to react normally, though the skeleton was still at the bottom of the screen. So it looks like pivot joints added after a group move work like they should.

I reset to your original code and then moved the transition to inside the touch event right before the gameUI:dragBody and the first touch joint works perfect, because it is created before the group has moved. You can swing the ragdoll around as you would expect and when released it reacts as it would without the group transition. However, the second touch joint shows the same problem. Looks like the bug is with touch joints created after a group moves. Don’t see any workarounds for that. [import]uid: 40137 topic_id: 13571 reply_id: 58209[/import]

Well, thanks for looking!

Oddly, this same code crashes the simulator with the latest daily build Version 2011.627 (2011.8.2) - BUT it does appear that the skeleton now draws properly in hybrid debug mode… curious… [import]uid: 12032 topic_id: 13571 reply_id: 58260[/import]

Does it behave properly when you transform using contentToLocal or localToContent ? [import]uid: 63787 topic_id: 13571 reply_id: 126205[/import]

Does it behave properly when you transform using contentToLocal or localToContent ? [import]uid: 63787 topic_id: 13571 reply_id: 126205[/import]