Hey guys - I’m having problems setting the mass value on a Rigidbody2D from any C# script. Its very easy to reproduce - simply attach either one of these scripts to a GameObject, and notice that the mass of the RigidBody2D component always remains at 1.
[RequireComponent(typeof(Rigidbody2D))]
public class TestRigidBody : MonoBehaviour
{
void Start()
{
GetComponent<Rigidbody2D>().mass = 0.1f;
}
}
or:
public class TestRigidBody : MonoBehaviour
{
void Start()
{
Rigidbody2D newRigidBody = this.gameObject.AddComponent<Rigidbody2D>();
newRigidBody.mass = 0.1f;
}
}
Setting other parameters (gravity scale, drag, etc) works fine, but the mass never changes. Am I missing something amazingly obvious here?