Currently there’s a box object that rotates around the planet object in a clockwise direction. When I set the joint motorspeed to a positive value, the box orbits clockwise in a normal speed. But, when I set the properties with negative values, it doesn’t move counterclockwise, rather clockwise, but sped up. How do you get an object to orbit around another object in a counterclockwise direction using pivot joint?
local physics = require "physics" physics.start() physics.setGravity( 0, 0 ) physics.setDrawMode( "hybrid" ) local cw, ch = display.contentWidth/2, display.contentHeight/2 planetImg = "earth.png" planetGroup = {} local planetBod = display.newCircle( 100, 100, 60); physics.addBody( planetBod, "kinematic", {radius = 50} ) planetBod.x, planetBod.y = cw, ch planetBod.angularVelocity = 50 local box = display.newRect( cw, 400, 50, 50); physics.addBody( box, "dynamic" ) local joint = physics.newJoint( "pivot", planetBod, box, planetBod.x, planetBod.y ) joint.isMotorEnabled = true joint.motorSpeed = -15 joint.maxMotorTorque = -20
