How do you get an object to orbit around another object in a counterclockwise direction using pivot joint?

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

Like this?

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

Hey Scott,

Actually that doesn’t work. I’m not sure if it’s a glitch or something. But, the rotation is still clockwise.

I give it another look when I get a chance

This irregularity is absurd. Unless I’m not clearly understanding the documentation on pivot joint rotation, there seems to be no clear pattern on what the joint motorSpeed and maxMotorTorque need to be set to in order to have an object rotate in a counter or clockwise rotation.

Figured it out 

planetBod.angularVelocity = -50

Flip bodies and it works  :slight_smile:

local joint = physics.newJoint( "pivot", box, planetBod, planetBod.x, planetBod.y )

EDIT : Solution of scottrules44 is better and I like it.

Like this?

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

Hey Scott,

Actually that doesn’t work. I’m not sure if it’s a glitch or something. But, the rotation is still clockwise.

I give it another look when I get a chance

This irregularity is absurd. Unless I’m not clearly understanding the documentation on pivot joint rotation, there seems to be no clear pattern on what the joint motorSpeed and maxMotorTorque need to be set to in order to have an object rotate in a counter or clockwise rotation.

Figured it out 

planetBod.angularVelocity = -50

Flip bodies and it works  :slight_smile:

local joint = physics.newJoint( "pivot", box, planetBod, planetBod.x, planetBod.y )

EDIT : Solution of scottrules44 is better and I like it.