I’ve noticed that the attributes that are said to apply to a distance joint are not working right.
http://developer.anscamobile.com/content/game-edition-physics-joints
Whenever I try to set frequency or dampingRatio, the latter instruction is effective, as if I had set the frequency only. The dampingRatio cannot be manipulated. Setting joint.length is also ineffective.
myJoint.frequency = 4711 – IGNORED
myJoint.dampingRatio = 2
Effect: frequency(!) will be 2, and dampingRatio remains 0.
myJoint2.dampingRatio = 4711 – IGNORED
myJoint2.frequency = 2
Same effect: frequency will be 2, and dampingRatio remains 0.
Also, http://developer.anscamobile.com/reference/index/jointlength suggests that the joint length of distance joints can be set and read. However, setting it seems to have no effect whatsoever.
Here’s my example code:
local physics = require( "physics" )
physics.start()
physics.setDrawMode( "debug" )
local ground = display.newRect( 1,445,319,34)
physics.addBody( ground, "static", { friction=0.5, bounce=0.3 } )
local rect = display.newRect(60,180,60,60)
local crate = display.newRect(60,280,60,60)
local rect2 = display.newRect(200,180,60,60)
local crate2 = display.newRect(200,280,60,60)
physics.addBody( rect, { density=500.0, friction=0.5, bounce=0.3 } )
physics.addBody( crate, { density=500.0, friction=0.5, bounce=0.3 } )
physics.addBody( rect2, { density=500.0, friction=0.5, bounce=0.3 } )
physics.addBody( crate2,{ density=500.0, friction=0.5, bounce=0.3 } )
local myJoint = physics.newJoint( "distance", crate, rect, crate.x, crate.y, rect.x, rect.y )
local myJoint2 = physics.newJoint( "distance", crate2, rect2, crate2.x, crate2.y, rect2.x,rect2.y )
print("BEFORE myJoint.frequency="..myJoint.frequency .. " myJoint.dampingRatio="..myJoint.dampingRatio)
myJoint.length = 1 -- IGNORED
myJoint.frequency = 4711 -- IGNORED
myJoint.dampingRatio = 2
print("AFTER: myJoint.frequency="..myJoint.frequency .. " myJoint.dampingRatio="..myJoint.dampingRatio)
print("BEFORE myJoint2.frequency="..myJoint2.frequency .. " myJoint2.dampingRatio="..myJoint2.dampingRatio)
myJoint.length = 10000 -- IGNORED
myJoint2.dampingRatio = 4711 -- IGNORED
myJoint2.frequency = 2
print("AFTER: myJoint2.frequency="..myJoint2.frequency .. " myJoint2.dampingRatio="..myJoint2.dampingRatio)
You’ll see in the console output that the frequency is set for both joints yet the dampingRatio is 0.
The objects also behave the exact same way.
I’m doing something wrong or is that really a bug? I really do suspect the latter. [import]uid: 85260 topic_id: 14869 reply_id: 314869[/import]