shrinking mass and scale

with this script how can i make it so that the objects scale shrinks at the same rate as the mass shrinks, so the scale will reach 0 at the same time the mass does?

float scale;
private Rigidbody rb;
private Rigidbody otherRB;
Vector3 temp;

// Use this for initialization
void Start()
{
    rb = GetComponent<Rigidbody>();
    scale = .01f;//(rb.mass - otherRB.mass) / 300;

}

void OnTriggerStay(Collider other)
{
    

    otherRB = other.GetComponent<Rigidbody>();
    if (other.gameObject.tag == "Death")
    {
        
        temp = transform.localScale;

        temp.x -= scale;

        temp.y -= scale;

        temp.z -= scale;

        rb.mass -= (rb.mass - otherRB.mass)/300;

        transform.localScale = temp;
    }

        
}

Right now you are reducing each of the scale axis by 0.1f (if I am not mistaken). To reduce the mass by the same “percentage” you’ll need to calculate the percentage of the scale’s axis reduction value. So you’d probably do something like float percentage = .1f / temp.x; This is basically the percentage of the amount you need to scale the mass with.

For mass you’ll do something like deductionValue = mass * percentage / 100; and you’ll get the exact amount you want to deduct from mass so later you can do mass -= deductionValue.

Hope that helps/works.