Rotating a physics body

I have 3 physics bodies: a small circle connected to a large circle by a thin rectangle.

At some point in my program, I connect the small circle to a fourth body: a large circle set as a sensor.

When that happens, I create a pivot joint between the large sensor circle and the small circle.

Once that is complete, I want to (however unwise) rotate the large circle around the location of the joint.

Would anyone know how to do this? Obviously, I can’t just rotate the display group the three objects are in, because they are physics objects.

Any help is much appreciated.

Thanks,

Matt. [import]uid: 8271 topic_id: 6016 reply_id: 306016[/import]

Not sure if I get your question, but:

Obviously position all components then set as physics objects. I’m assuming the first two circles are bound to each end of the rect by weld joints.

Create the third circle, position it where it’s supposed to be in relation to circle 1. Make as physics object, set isSensor to true (I’m sure you’ve done all this already), then create joint, like:

-- coords of centre of 1st & 3rd circle  
local c1c3Joint = physics.newJoint( "pivot", c1, c3, 100, 100, 100, 150 )   
  
c1c3Joint.isMotorEnabled = true  
c1c3Joint.motorSpeed = 100 -- or whatever  
c1c3Joint.maxMotorTorque = 100000 -- a good starting point  
  

Torque is important or it won’t have the power to move.

You can then hide the sensor until you need it. No need to switch off physics, just ignore sensor callbacks while isVisible == false.

This what you’re after? [import]uid: 3953 topic_id: 6016 reply_id: 21343[/import]

That’s an excellent suggestion, thanks.

I’d been wondering if my approach was simply wrong. I think you’re right that using motors is probably the right way to go.

m [import]uid: 8271 topic_id: 6016 reply_id: 21394[/import]