I have the movement and rotation restrained properly, but the simulation is not behaving like it should. both objects are rigid body objects.
1 Answer
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!
-
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$– wcharginCommented 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$– p2orCommented Jan 7, 2016 at 16:03
-
$\begingroup$ @poor um.. what favor? $\endgroup$ Commented Jan 7, 2016 at 17:00