Jump to content

How to make a motorized wheel using Box2D plugin?


kleepklep
 Share

Recommended Posts

I purchased both the Box2D plug-in and R.U.B.E. and I'm in the process of converting a Flash game to HTML5. One thing I'm stuck on is how to make a motorized wheel. I have a large wheel circle with a small gear circle in the center of it and I'm using a revoluteJoint with a motor.

This does not spin the wheel:

var wheel = levelScene.getBody('wheel');wheel.friction = 1;var gear = levelScene.getBody('gear');//bodyA, bodyB, ax, ay, bx, by, motorSpeed, motorTorque, motorEnabled, lowerLimit, upperLimit, limitEnabledgame.physics.box2d.revoluteJoint(wheel, gear, 0, 0, 0, 0, 3, 1000, true);
Changing the revoluteJoint line to this spins the gear and wheel but the wheel just spins in place:

game.physics.box2d.revoluteJoint(wheel, gear, 0, 0, 0, 0, 3, 1000, true, 1000000, 100000, true);
Not sure why setting the upper and lower limits would cause it to spin or why it's not able to move across the static body it's resting on.

Any ideas? What I'm trying to do is have a motorized wheel that never stops. I have both bodies set so sleeping is not allowed.

post-12464-0-64856600-1444184550.jpg

Link to comment
Share on other sites

  • 3 weeks later...

Turns out the my motor speed setting of 3 wasn't enough to propel the wheel in this new environment even though the gravity, density and friction settings of everything seem to be the same. Will have to look into that.

 

So this works, though I'm now creating the joint in R.U.B.E. instead.
 

var joint = game.physics.box2d.revoluteJoint(wheel, gear, 0, 0, 0, 0, -300, 1000, true);

Other code that may be helpful to others:
 

// set motor speedjoint.SetMotorSpeed(100);// start motorjoint.EnableMotor(true);// stop motorjoint.EnableMotor(false);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...