# How can I make my gear simulation in the BGE work?

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

# How can I make my gear simulation work?

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

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)

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

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

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)

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

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.

Now we can test the simulation:

# Yay! it works!

• 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. – immibis Jan 4 '16 at 0:52
• 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. – X-27 the fluffy unicorn Jan 4 '16 at 1:10
• "(this is optional)"—[citation needed]! :) – wchargin Jan 4 '16 at 6:52
• Returned the favour again. Selecting the "favorite color" is definitely the best part ;) lol. Thanks for this great answer! – p2or Jan 7 '16 at 16:03
• @poor um.. what favor? – X-27 the fluffy unicorn Jan 7 '16 at 17:00