19
$\begingroup$

enter image description here

I have the movement and rotation restrained properly, but the simulation is not behaving like it should. both objects are rigid body objects. enter image description here

How can I make my gear simulation work?

$\endgroup$

1 Answer 1

20
$\begingroup$

This problem is caused by the moment and rotation restraints on the top gear. To fix this, I recommend removing them:

enter image description here

Now, if you run the simulation,

The top gear is responding to the collision with the bottom gear. This is progress. (smile! - it almost works)

enter image description here

We just need to get the gear to ignore translation, but still respond to rotation. This can be done using a rigid body joint.

enter image description here

Now, we need to apply the right settings to the joint.

enter image description here

This joint will allow no translation, and will only allow rotation along the X axis. But this joint works relative to another object. We need to put a stationary object in the target field.

A static cube will work. (any other static object should also work as well)

enter image description here

Now, we simply set that cube to be the target object.

enter image description here

The top gear will now have it's X,Y, and Z translation locked to the cube's position, and since it is static, it will not be moving. The top gear's Y and Z rotation is also locked to the cubes rotation, and since it is a static cube, it also will not be rotating. The last step (this is optional) is to paint it your favorite color.

enter image description here

Now we can test the simulation:

enter image description here

Yay! it works!

$\endgroup$
6
  • 6
    $\begingroup$ It's pretty cool that the physics engine is able to simulate this, but it also seems like a big waste of computational power - usually a game would just hard-code the fact that the gears' rotational speeds are linked, and calculate them directly, instead of simulating collisions between all the gear teeth. $\endgroup$ Commented Jan 4, 2016 at 0:52
  • 1
    $\begingroup$ I know, this type of simulation would be for checking if gears actually line up and would actually work. There would be no point to ever actually calculate this for a game. $\endgroup$ Commented Jan 4, 2016 at 1:10
  • $\begingroup$ "(this is optional)"—[citation needed]! :) $\endgroup$
    – wchargin
    Commented Jan 4, 2016 at 6:52
  • $\begingroup$ Returned the favour again. Selecting the "favorite color" is definitely the best part ;) lol. Thanks for this great answer! $\endgroup$
    – p2or
    Commented Jan 7, 2016 at 16:03
  • $\begingroup$ @poor um.. what favor? $\endgroup$ Commented Jan 7, 2016 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .