Setting Inertia Tensor Manually

Hi all -

I have been getting this common error message from a few of my rigid body objects recently: “Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor’s mesh shapes! Please change mesh geometry or supply a tensor manually!”

Now, I know exactly WHY I’m getting this message: it’s because some of my objects are “paper-thin” two-dimensional objects for which 3-dimensional inertia tensors don’t make sense.

What I can’t figure out is how to “supply a tensor manually.” I’ve tried putting the following code in a lot of different places, but it has no effect:

GetComponent<Rigidbody>().inertiaTensor = new Vector3(1,1,1);
GetComponent<Rigidbody>().inertiaTensorRotation = Quaternion.identity;

Should this code go in Start(), or Awake(), or Update(), or FixedUpdate(), or right after I assign meshes, or somewhere else?

I should also note that the collision meshes I’m using have been procedurally generated and are assigned to the game objects in script.

Thanks so much!

One reason it can fail is if one of your colliders has a dimension that is zero. Like a plane.