How to attach joint object

I want to make pan scales. For attach bowl to stick i use ‘pivot’ joint. When i change bowl rotation using transition.to, bowl moves out.

Link on video with example: https://youtu.be/ivnfL1b3Kac

I don’t understand how to solve this simple problem.

Hi @vadozza,

How are you attaching the “pans” to the “bowl”? Which joint type and parameters?

Can you post some basic code for others and staff to look at? Please remember to surround it by “lua” tags for clarity in the forum:

[lua] -- your code [/lua]

Best regards,

Brent

Brent, thanks for response. Following code with attaching “bowl” to “stick”.

bowlLeft.x = -98 bowlLeft.y = -67 bowlRight.x = 98 bowlRight.y = -67 physics.addBody( bowlLeft, "dynamic", {bounce=0.3} ) physics.addBody( bowlRight, "dynamic", {bounce=0.3} ) local staffToStickJoint = physics.newJoint( "pivot", staff, stick, 0, -14) local stickToBowLeftJoint = physics.newJoint( "pivot", stick, bowlLeft, -98, -67) local stickToBowRightJoint = physics.newJoint( "pivot", stick, bowlRight, 98, -67) transition.to( stick, {transition=easing.outExpo, rotation=30, time=1000})

Hi @vadozza,

OK, thanks for clarifying. Basically, using transitions to move complex physical structures that are attached with joints can cause the behavior you’re seeing. Corona transitions move/rotate the object independently from the physics engine, and while that’s usually OK when you’re transitioning just simple objects, when joints come into the picture, Box2D can struggle to “catch up” to what’s happening to the objects that are joined to the core object which is being moved/rotated by transitional movement.

The best way to handle your situation is to move the stick by physical means, i.e. “rotate” it my applying force to either end of it, or giving it some amount of rotational torque.

Hope this helps,

Brent

Hi @vadozza,

How are you attaching the “pans” to the “bowl”? Which joint type and parameters?

Can you post some basic code for others and staff to look at? Please remember to surround it by “lua” tags for clarity in the forum:

[lua] -- your code [/lua]

Best regards,

Brent

Brent, thanks for response. Following code with attaching “bowl” to “stick”.

bowlLeft.x = -98 bowlLeft.y = -67 bowlRight.x = 98 bowlRight.y = -67 physics.addBody( bowlLeft, "dynamic", {bounce=0.3} ) physics.addBody( bowlRight, "dynamic", {bounce=0.3} ) local staffToStickJoint = physics.newJoint( "pivot", staff, stick, 0, -14) local stickToBowLeftJoint = physics.newJoint( "pivot", stick, bowlLeft, -98, -67) local stickToBowRightJoint = physics.newJoint( "pivot", stick, bowlRight, 98, -67) transition.to( stick, {transition=easing.outExpo, rotation=30, time=1000})

Hi @vadozza,

OK, thanks for clarifying. Basically, using transitions to move complex physical structures that are attached with joints can cause the behavior you’re seeing. Corona transitions move/rotate the object independently from the physics engine, and while that’s usually OK when you’re transitioning just simple objects, when joints come into the picture, Box2D can struggle to “catch up” to what’s happening to the objects that are joined to the core object which is being moved/rotated by transitional movement.

The best way to handle your situation is to move the stick by physical means, i.e. “rotate” it my applying force to either end of it, or giving it some amount of rotational torque.

Hope this helps,

Brent