Distance and Pivot Joints Not Working??

Hi all,

I have been trying to get distance and pivot joints working. I am using the accelerometer to produce movement of one object that is connected by a distance joint. However when the phone is moved quickly enough the distance joint stretches. The pivot joints attached also rotate to far. Any help with this matter would be great. I will post my code below.

Thanks,
Chris

[lua]local physics = require “physics”
physics.start();
physics.setGravity(0, 9.8);
physics.setDrawMode(“hybrid”);

system.setAccelerometerInterval( 100 )

local balloon = display.newCircle(160, 160, 15);
physics.addBody( balloon, “static”, { radius = 15, density = 1000000000} )
balloon:setFillColor(255,0,0);

local ground = display.newRect(0,400, 320, 400);
physics.addBody( ground, “static”, {density = 1});

local leftArm = display.newRect(0,0,25,8);
physics.addBody( leftArm, {density = 1});
leftArm.gravityScale = 0;

local rightArm = display.newRect(0,0,25,8);
physics.addBody( rightArm, {density = 1});

local leftLeg = display.newRect(0,0,25,8);
physics.addBody( leftLeg, {density = 1});

local rightLeg = display.newRect(0,0,25,8);
physics.addBody( rightLeg, {density = 1});

local body = display.newCircle(0, 0, 15);
physics.addBody( body, {radius = 15, density = 1});

body:translate(160, 240);
leftArm:translate(128, 225);
rightArm:translate(168, 225);
leftLeg:translate(140, 260);
rightLeg:translate(156, 260);
leftLeg.rotation = 90;
rightLeg.rotation = 90;
bodyLeftArm = physics.newJoint( “pivot”, leftArm, body, 150,230 )
bodyLeftArm.isLimitEnabled = true – (boolean)
bodyLeftArm:setRotationLimits( -80, 0 )

bodyRightArm = physics.newJoint( “pivot”, rightArm, body, 170,230 )
bodyRightArm.isLimitEnabled = true – (boolean)
bodyRightArm:setRotationLimits( -60, 45 )

bodyLeftLeg = physics.newJoint( “pivot”, leftLeg, body, 155,250 )
bodyLeftLeg.isLimitEnabled = true – (boolean)
bodyLeftLeg:setRotationLimits( -30, 5 )

bodyRightLeg = physics.newJoint( “pivot”, rightLeg, body, 165,250 )
bodyRightLeg.isLimitEnabled = true – (boolean)
bodyRightLeg:setRotationLimits( -5, 30 )

balloonLeftArm = physics.newJoint( “distance”, leftArm, balloon, leftArm.x - 10, leftArm.y, balloon.x, balloon.y )
balloonLeftArm.length = 80;

local moveTed = function(e)
balloon.x = display.contentCenterX + (display.contentCenterX * (e.xGravity * 1.5))
if((balloon.x - balloon.width * 0.5) < 0) then
balloon.x = balloon.width * 0.5
elseif((balloon.x + balloon.width * 0.5) > display.contentWidth) then
balloon.x = display.contentWidth - balloon.width * 0.5
end
end

Runtime:addEventListener(“accelerometer”, moveTed) [import]uid: 126017 topic_id: 31787 reply_id: 331787[/import]

I’ve noticed some weirdness with pivot joints as well. Haven’t had time to closely explore whether it was a bug or not though.

I tested your code on my 3GS with build 912 and for the most part it seems to work ok. I do see some separation on the distance joint, but the pivot joint limits seem to be working fine. The problem might be more clear if you put together a demo that plays on its own instead of relying on testing with the accelerometer. [import]uid: 135827 topic_id: 31787 reply_id: 126963[/import]

I’ve noticed some weirdness with pivot joints as well. Haven’t had time to closely explore whether it was a bug or not though.

I tested your code on my 3GS with build 912 and for the most part it seems to work ok. I do see some separation on the distance joint, but the pivot joint limits seem to be working fine. The problem might be more clear if you put together a demo that plays on its own instead of relying on testing with the accelerometer. [import]uid: 135827 topic_id: 31787 reply_id: 126963[/import]