0
\$\begingroup\$

I've realized this gear using primitive. enter image description here

My object is:

  • Main cylinder with with a Rigidbody and a script who rotate Y axis
    • All Prism as child who has MeshCollider

enter image description here

I've got also a pivot for each gear.

The problem is that the right gear not rotate when "prism" collide with others. The collision not happen.

Any ideas ?

Thanks

\$\endgroup\$
5
  • \$\begingroup\$ How are you causing the gear to rotate? \$\endgroup\$
    – DMGregory
    Jan 27, 2018 at 19:21
  • \$\begingroup\$ transform.Rotate (new Vector3 (x, y, z) * SpeedRotation); \$\endgroup\$
    – stighy
    Jan 27, 2018 at 19:25
  • \$\begingroup\$ The problem is that not cause moving the second gear \$\endgroup\$
    – stighy
    Jan 27, 2018 at 19:25
  • 3
    \$\begingroup\$ That'll do it. Transform.Rotate doesn't impart a physics force. Can you try rotating the gear with a Rigidbody torque or angular velocity and see if that changes anything? \$\endgroup\$
    – DMGregory
    Jan 27, 2018 at 19:26
  • \$\begingroup\$ Are the teeth passing through eachother? What exactly do you mean by “the collision is not happening”? \$\endgroup\$
    – Fabio S.
    Jan 27, 2018 at 19:41

1 Answer 1

2
\$\begingroup\$

When you have a rigidbody on a game object, you generally should refrain from manipulating its transform directly. Doing so confuses the physics engine, because you are literally teleporting the object around.

If you want to manipulate the object, use the methods of rigidbody instead. If you want the object to turn, use rigidbody.AddTorque.

By the way: If gear physics are a central game mechanic of your game (like in a mechanical puzzle game) you might want to implement them yourself instead of relying on the Unity physics engine. Having so many small physics object in the scene with interactions which matter for the gameplay is going to end in a disaster.

\$\endgroup\$

You must log in to answer this question.

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