Rigidbody mass not updating in inspector after calling SetDensity

So, I have a prefab with a Rigidbody and a C# script attached. The prefab has a cube child object with a collider on it. The prefab is instantiated at runtime when the user clicks and the user can change the scale of the object. I call SetDensity on the Rigidbody whenever the volume gets changed in this way but the mass value in the inspector doesn’t seem to change from it’s initial value that was set in the prefab. If I print out the value of rigidbody.mass just after I call SetDensity it all looks fine - the value is different as it should be but it just doesn’t change in the inspector.

It doesn’t actually matter as long as the physics engine is recognising that the mass has changed but it does seem weird… anyone else run into this?

Thanks :smiley:

Why not use

rigidbody.mass = 100;

I came across this, too. It actually DOES change in-game, but the inspector doesn’t show it. Add:

rigidbody.mass = rigidbody.mass;

The first line shows that the change was made; it will be different than in the inspector. The second line will change the value shown in the inspector, but I plan on removing that for release.