x


What does the "compute mesh inertia tensor failed" error mean?

I have a simple "third person cam" space shooter using a GameObject which contains a valid 3D ship mesh, and various planes used for effects (engine glow and crosshair).

I would like the position of this object to be defined by an invisible rigidbody sphere. However, when I place the rigidbody sphere at the top of the GameObject, I get compile errors:

Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!

Apparently this is caused by the auto-tensor-assignment process, which trips up on zero mass meshes (ie. the planes). I don't want these hackily put in seperate game objects and positioned each frame. Is there any way I can get this to behave? I'm sure the Tutorial has rigidbody objects containing sprites but I can't seem to figure out what part I'm doing differently. I tried adding a line on Awake() to set up a default tensor manually, as such:

rigidbody.inertiaTensor = Vector3(1, 1, 1);

But that didn't fix it either. Anyone got any suggestions?

more ▼

asked Nov 17 '09 at 12:12 PM

Novodantis gravatar image

Novodantis
141 1 4 6

I had the same error after adding a rigidbody to a plane, to be able to do a raycast on the plane. I could ignore the error without any noticeable consequences. There may be other consequences though (perhaps memory related issues), but as it was for a gameplay prototype, I had no problems ignoring the issue.

Jun 13 '11 at 11:08 AM bernardfrancois

@bernardfrancois: raycasting does not depend on rigidbodies, only colliders. Remove the rigidbody from the plane.

Jun 13 '11 at 04:31 PM Eric5h5
(comments are locked)
10|3000 characters needed characters left

5 answers: sort voted first

This error most commonly arises from placing a Rigidbody on a Plane, so you need to check whether the GameObject in question has a Mesh Collider component which uses "plane" as its mesh. This is because the plane mesh has no depth, and therefore the rigidbody has no mass. You can solve this by using a very thin box (if you really want something which behaves physically like a thin plane), although from the rest of your description it sounds like you're after something else.

Just to clarify - there's no such thing as a "rigidbody sphere" - these are two separate components. The Rigidbody component does not describe the physical shape of the object. The Rigidbody component takes is physical form from the collider component attached to the same gameobject - or, in the case of compound colliders - the combination of colliders attached to each of the child gameobjects which may be parented to it.

So, for a Rigidbody which collides using a spherical shape, you need to add the Rigidbody component, plus a Sphere Collider Component to that gameobject, or a child of that gameobject.

It's entirely possible to display a sprite that corresponds to such a GameObject's position. If you're using the spritemanager (from the wiki), it's simply a case of using the Linked Sprite Manager, and adding a sprite which references the gameObject as the 'client' parameter.

If the above doesn't help, please provide a bit more information about the arrangement of the gameobject hierarchy which is causing the errors!

more ▼

answered Nov 17 '09 at 12:40 PM

duck gravatar image

duck ♦♦
41k 92 148 415

(comments are locked)
10|3000 characters needed characters left

Do your child game objects have colliders attached? A game object that has children with individual colliders will collectively act as a compound collider (this is described somewhere in the Unity Manual in the Physics section - it's a technique to create collision shapes more complex than a sphere or cube), so if you have zero-volume plane/mesh colliders and a parent rigidbody, that might account for the warning. So I suggest you remove any colliders you really don't want or selectively replace them, e.g. replace a mesh collider with a box collider with non-zero width/height/depth. Or rearrange your objects is the children don't really need to be children.

If you still want to set the inertia tensor explicitly, you made the right call - here's another example setting it for a cylinder shape (extracted from some game physics book). But this is more appropriate for a refinement phase after getting the physics to basically work right and error-free.

function SetInertia() {
var inertia:Vector3;
// cylinder
inertia.x= rigidbody.mass*(1.0/12.0)*h*h+ rigidbody.mass*0.25*r*r;
inertia.y=  rigidbody.mass*0.5*r*r;
inertia.z = inertia.x;
rigidbody.inertiaTensor = inertia;

}

more ▼

answered Nov 17 '09 at 08:09 PM

technicat gravatar image

technicat
1.5k 10 11 34

(comments are locked)
10|3000 characters needed characters left

Okay, couldn't see the forest for all the trees! After re-reading your answers, I re-checked my hierarchy and realised I was so busy looking for colliders on the mesh of the ship and its components that might affect the tensor, I forgot to check for colliders on the actual planes of the sprites! Starting their life as unity GameObject meshes, they had colliders added by default of course. Thanks so much for your help, I am now a lot more happy/clear with how these physics entities go together =)

more ▼

answered Nov 19 '09 at 01:03 AM

Novodantis 1 gravatar image

Novodantis 1
1.7k 14 22 40

It is certainly not intuitive - I started making compound colliders (stack of spheres for a bowling pin) by adding all the colliders on the same game object, until I saw the Unity doc that recommends putting them on children.

Nov 19 '09 at 02:59 AM technicat
(comments are locked)
10|3000 characters needed characters left

I have a plane, that is a child of an Object ( capsule ) that has a RigidBody component, i removed the MeshCollider Component from the Child --> Plane , and the error disappeared.

more ▼

answered Nov 14 '11 at 07:53 AM

ifaris7 gravatar image

ifaris7
1 3 3 3

(comments are locked)
10|3000 characters needed characters left

if the game object that the script is attached to is a plane. EASY FIX! all you have to do i, remove the mesh collider and replace it with a box collider. its as simple as that!

more ▼

answered Jan 04 '12 at 01:17 PM

DAT gravatar image

DAT
1

Why do you answer a 2 years old question that has really good upvoted answers with an advice that is already in @Duck's answer?

Jan 04 '12 at 01:19 PM Bunny83

hmm im sorry i didn't relise that giving an answer could get you into trouble with some person that is hidden behind a username... very brave! you deserve a medal!

Feb 04 '12 at 06:07 AM DAT

You're not "in trouble"; it's a valid question. What was the point of this answer? Wanting to help is commendable, but you should add new information if you have it, not just repeat what's already been said.

Feb 04 '12 at 08:35 AM Eric5h5

Yes, okay I didn't realize that the question was that old haha. sorry for being moody in the last comment(pms? but im a guy haha). now thanks to your constuctive criticism I will watch what questions I answer ;)

Apr 11 '12 at 02:52 PM DAT

I'm glad you did it. You resolve my problem.

Dec 14 '12 at 10:15 AM alexaustralia
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1951
x1882
x21
x6

asked: Nov 17 '09 at 12:12 PM

Seen: 18644 times

Last Updated: Dec 14 '12 at 10:15 AM