Critical Issue With Pivot Joints In Newer Builds

In the newer builds of Corona (2012.776), pivot joints using the rotation function no longer work. The object would rotate for a fraction of a second then cease to move after that. No errors appear in the terminal.

Here is some demo code that worked flawlessly and error free in older builds of the SDK:

[lua]local physics = require"physics"

physics.start()

physics.setGravity( 0, 0 )

physics.setDrawMode(“hybrid”)

display.setStatusBar(display.HiddenStatusBar)

W = display.contentWidth
H = display.contentHeight

local anchor = display.newCircle(W/2, H/2, 5)
physics.addBody( anchor, “static”, { radius = 5, isSensor = true})
anchor:setFillColor(0,0,255)

local planet = display.newCircle(0,0, 10)
physics.addBody( planet, “dynamic”, { radius=bodySize, density=0.2, friction=0.1, bounce=0.5, isSensor = true, isAwake = true } )
planet.x = W/2; planet.y = H/4

myJoint = physics.newJoint( “pivot”, anchor, planet, planet.x, planet.y )

local function move()
anchor:rotate(0.8)
end

Runtime:addEventListener(“enterFrame”, move)[/lua]

This is a major issue for us since our game focuses on this feature. Checked through all the release notes to see if the rotation function was modified at all. Everything seems to be in place, correct me if something is mistaken.

Any assistance on this issue or support to get it fixed would be greatly appreciated. [import]uid: 40758 topic_id: 24289 reply_id: 324289[/import]

I made a few small joint changes to the joint and the move function.

This rotates it around. Seems to work :slight_smile:
Of course, that may not be how you want to do things, but I have a philosophy “ALAIW” or as long as it works. :slight_smile:

I also added a +4 to the anchor.x to center it on the anchor (so it’s connected to the center of the joint in question).
-Nick

[code]

local physics = require"physics"

physics.start()

physics.setGravity( 0, 0 )

physics.setDrawMode(“hybrid”)

display.setStatusBar(display.HiddenStatusBar)

W = display.contentWidth
H = display.contentHeight

local anchor = display.newCircle(W/2, H/2, 5)
physics.addBody( anchor, “static”, { radius = 5, isSensor = true})
anchor:setFillColor(0,0,255)

local planet = display.newCircle(0,0, 10)
physics.addBody( planet, “dynamic”, { radius=bodySize, density=0.2, friction=0.1, bounce=0.5, isSensor = true, isAwake = true } )
planet.x = W/2; planet.y = H/4

myJoint = physics.newJoint( “pivot”, planet, anchor, anchor.x+4, anchor.y )

local function move()
planet:rotate(0.8)
end

Runtime:addEventListener(“enterFrame”, move)

[/code] [import]uid: 61600 topic_id: 24289 reply_id: 98164[/import]

Thank you kindly,

Had to make some minor modifications to your code in the actual game, but regardless it worked. It seems rotation values have also changed, what would run at 0.8 in our game before, now has to be >1.0 in order for the object to move, anything less than 1, the object has a speed of 0.

Thanks again for your help :slight_smile: [import]uid: 40758 topic_id: 24289 reply_id: 98342[/import]

Hey nicholasclayg,

I implemented your code but unfortunately I need the anchors to be the ones rotating (in the actual game code I use a for loop to handle the rotating). I need to have different size planets orbiting at the same speed if they are the same distance from the anchors.

With this code I can give the two planets the same speed (2), yet the one with the larger physics body rotates slightly faster.

[lua]local physics = require"physics"

physics.start()

physics.setGravity( 0, 0 )

physics.setDrawMode(“hybrid”)

display.setStatusBar(display.HiddenStatusBar)

W = display.contentWidth
H = display.contentHeight

local anchor = display.newCircle(W/2, H/2, 5)
physics.addBody( anchor, “static”, { radius = 5, isSensor = true})
anchor:setFillColor(0,0,255)

local planet = display.newCircle(0, 0, 10)
physics.addBody( planet, “dynamic”, { radius=10, density=0.2, friction=0.1, bounce=0.5, isSensor = true, isAwake = true } )
planet.x = W/2; planet.y = H/2+50

myJoint = physics.newJoint( “pivot”, planet, anchor, anchor.x, anchor.y )

local anchor2 = display.newCircle(W/2, H/2, 5)
physics.addBody( anchor2, “static”, { radius = 5, isSensor = true})
anchor2:setFillColor(0,0,255)

local planet2 = display.newCircle(0, 0, 10)
physics.addBody( planet2, “dynamic”, { radius=30, density=0.2, friction=0.1, bounce=0.5, isSensor = true, isAwake = true } )
planet2.x = W/2; planet2.y = H/2-50

myJoint2 = physics.newJoint( “pivot”, planet2, anchor2, anchor.x, anchor.y )

local function move()
planet:rotate(2)
planet2:rotate(2)
end

Runtime:addEventListener(“enterFrame”, move)[/lua]
Before the daily build update I had the anchors rotating with the planets on the other end of the joint it worked perfectly.

P.S. We have submitted this as a bug for the new build.
Thanks for your input, it’s much appreciated.

Brian P.

[import]uid: 40731 topic_id: 24289 reply_id: 98359[/import]