Error: Actor must have shapes or a fixed weight?

Hi everybody,

Im new in Unity. Currently Im analyzing, how accurate Unity is in simulating mechanical systems.

Right now I just wanted to import an object (both formats .obj and .fbx show the same problem) and give it a fixed density, so that its mass and inertia tensor is calculated automatically.
The shape of the object is designed in an engineering CAD tool ProEngineer. I saved the model as an .obj object and imported it to unity. It looks great but shows this specific issue.

I wrote this script and with it, the following error occurs.

using UnityEngine;
using System.Collections;

public class SetDensity: MonoBehaviour {

	void Start ()
        {
		this.gameObject.rigidbody.SetDensity(0.00785f);
		Debug.Log( this.gameObject.tag + "mass is: " + rigidbody.mass);	
	}
	 
}

Actor::updateMassFromShapes: Actor must have shapes or a fixed weight!
UnityEngine.Rigidbody:SetDensity(Single)
SetDensity:Start() (at Assets/Scripts/SetDensity.cs:10)

Can someone please help me? I dont have a clue where I can find this error.

Thanks a lot.

Rox

Does the object have a collider?

No. Should I add one?

I did not add one because I dont want to test collisions yet.

Cool, thanks! I added a collider and it fixed it. Thanks

You’re welcome :slight_smile:

If the rigidbody has no collider it will have no volume to use to set the mass by density, it’s a vicious cycle! :wink: