I’m currently trying to implement a rotating platform into my game. SO far, I’ve ended up with this code:
-- create an invisible, static body as the "anchor"
local anchorA = display.newCircle( -100, -100, 10 )
physics.addBody( anchorA, "static" )
localGroup:insert(anchorA)
-- create and position the dynamic platform
local rotaterA = display.newImage( "platform.png" )
rotaterA.x, rotaterA.y = 170, 270
physics.addBody( rotaterA, "dynamic", { friction=1, bounce=.2 } )
localGroup:insert(rotaterA)
-- create a pivot to join the anchor to the platform
local pivot = physics.newJoint(
"pivot", -- joint type
anchorA, rotaterA, -- objects to join together
rotaterA.x, rotaterA.y -- physics world location to join at
)
-- limit the spinning by 'damping' the rotation
rotaterA.angularDamping = 5
-- power the joint's motor
pivot.isMotorEnabled = true
pivot.motorSpeed = 50
pivot.maxMotorTorque = 100000
This code works fairly well, but the problem is the platform can be pushed by external forces, such as a ball falling onto the platform, which I don’t want. Is there any way to stabilize the platform without breaking the physics? [import]uid: 100403 topic_id: 21269 reply_id: 321269[/import]