I want to achieve the effect of wheels turning each other like gears.
I have created some wheels; circular physics bodies that have pivot joints to a static body. The wheels are positioned so they are touching. I apply isMotorEnabled true on one of them with a motorSpeed and it rotates as expected…
However I would expect the wheel that touches the motorised wheel to turn in the opposite direction but it doesn’t. Now the bizarre thing is that if I create another non-jointed dynamic physics object and position it where the two wheels touch, it will fall away and leave the wheels turning and interacting as I would expect them to.
Can anyone shed any light on this for me? I want to achieve this affect without having to place obsolete bodies on every point a wheel contacts another.
local physics = require("physics")
physics.start()
local \_W = display.contentWidth
local \_H = display.contentHeight
--\> Board
local board = display.newRect(0, 0, \_W, \_H)
board:setFillColor(140, 140, 140)
physics.addBody( board, "static", { friction=0.5, bounce=0.3 } )
--\> Wheel 1
local wheel1 = display.newCircle( \_W/2, \_H/2, 50 )
wheel1:setFillColor(128,128,128)
physics.addBody( wheel1, { density=5, friction=5, bounce=0, radius=5 } )
wheel1Joint = physics.newJoint( "pivot", board, wheel1, wheel1.x, wheel1.y, 0, 0 )
wheel1Joint.isMotorEnabled = true
wheel1Joint.motorSpeed = 100
wheel1Joint.maxMotorTorque = 100000
--\> Wheel 2
local wheel2 = display.newCircle( \_W/2, \_H/2+75, 25 )
wheel2:setFillColor(128,128,128)
physics.addBody( wheel2, { density=5, friction=5, bounce=0, radius=25 } )
wheel2Joint = physics.newJoint( "pivot", board, wheel2, wheel2.x, wheel2.y, 0, 0 )
--\> Box --\> Note: without the box the wheels don't interact, very strange
local box = display.newRect(\_W/2-20, \_H/2+50, 40, 40)
box:setFillColor(140, 140, 140)
physics.addBody( box, { density=5, friction=5, bounce=0} )
Please help.
[import]uid: 62617 topic_id: 16627 reply_id: 316627[/import]
