Hello, the short of it is I can’t seem to get a piston joint motor to work.
Below is some copy & paste code that shows an example of two objects jointed together with a motor enabled. Nothing appears to happen, though the joint does exist. If I change the joint type from piston to pivot the motor seems to work fine. The docs don’t seem to contain an example of a working piston joint w/ a motor so maybe(probably) I am just missing something.
Any advice on what’s going on would be mucho appreciated.
[lua]
–init physics
local physics = require(“physics”)
physics.start()
physics.setDrawMode(“hybrid”)
–create a static object which iam kind of using as the anchor
local staticAnchor = display.newCircle( 100, 100, 25 )
physics.addBody(staticAnchor)
staticAnchor.bodyType= “static”
staticAnchor.x = 200
staticAnchor.y = 200
staticAnchor:setFillColor(255,0,0, 255)
–create the dynamic object that will be jointed to the anchor object
local pistonObj = display.newCircle( 100, 100, 40 )
physics.addBody(pistonObj)
pistonObj.bodyType= “dynamic”
pistonObj:setFillColor(0,255,0, 255)
pistonObj.y = 300
–and here is the joint
local jointMotor = physics.newJoint( “piston”, staticAnchor, pistonObj, staticAnchor.x,staticAnchor.y , 0,10 )
jointMotor.isMotorEnabled =true
jointMotor.isActive = true
jointMotor.motorSpeed = 6000
jointMotor.maxMotorTorque = 10000
jointMotorisCollideConnected = false
–make ground
local ground = display.newRect(0, 1000, 1000, 100)
ground.y = display.contentHeight -50
physics.addBody(ground)
ground.bodyType = “static”
ground:setFillColor(255,255,255, 255)
[/lua]