1
\$\begingroup\$

The Problem

I've run into a physics issue in my Unity project, and have put together a simple example scene to illustrate it. Hopefully someone will be able to tell me if I'm doing something wrong.

In my real game, I have a physics-based character with a limb that can rotate along it's length (think holding your arm out straight and twisting it). The limb and body are both rigid bodies and are connected by a Configurable Joint. My problem is that when the joint twists the limb, it also twists the body. That's not entirely surprising, Newton's 3rd law and all. But, I should be able to fix this by changing the masses of the connected objects, right? If I make the limb much less massive than the body, the limb should move much more relative to the body, right? Well, apparently that's only partially right, at least according to Unity.

Simple Test/Reproduction

Here's my simple test scene, it involves only two cubes:

Left cube properties
(Left cube "Big Cube" selected)

Right cube properties
(Right cube "Little Cube" selected, showing joint anchor position)

These cubes are identical except:

  • Transform position and scale
  • Little Cube has a mass of 5.
  • Big Cube has a mass of 100 (and is scaled 2x for clarity).
  • Little Cube has a Configurable Joint on it, connected to Big Cube.

Now, watch what happens when I move the cubes toward or away from each other using the joint:

Moving the cubes using the joint

Big Cube barely moves, while Little Cube is moving all over the place. That's exactly what I would expect.

Now, let's try the same thing, but with rotation instead of position/translation:

Rotating the cubes using the joint

Huh? The two cubes are moving in equal and opposite amounts. I would expect Big Cube to barely rotate at all, and Little Cube to rotate a lot, just like with the previous test.

WHY?

And how do I fix it so that the joint doesn't rotate the body (or at least doesn't rotate it much)?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Well, turns out the answer was pretty simple:

Colliders

Colliders are present by default on the Cube primitive, but I'd been deleting them because I don't need/want collision detection. Since I'm pretty new to Unity, I didn't realize that Colliders influence the Rigidbody physics system in ways other than just detecting collisions. In particular:

If you don't set the center of mass from a script it will be calculated automatically from all colliders attached to the rigidbody.

...positioned at this body's center of mass...

Inertia tensor is a rotational analog of mass: the larger the inertia component about a particular axis is, the more torque that is required to achieve the same angular acceleration about that axis.

...

If you don't set the inertia tensor from a script, it is calculated automatically from all colliders attached to the Rigidbody.

This tells me that the same amount of torque will be required to rotate any given rigidbody unless inertiaTensor is set, either manually, or through the use of Colliders.

Adding Colliders to the boxes causes the to behave as expected.

\$\endgroup\$

You must log in to answer this question.

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