Add weight every time something enters trigger

Hi! I have a project where you can play with three characters with several weights. The character ar NOT rigidbodies, thery have saved their weights in a variable in the player controller script. I want an object to be a trigger that breaks as soon as enough ‘weight’ is added. So every character can one by one be choosen as an active player and stand on this particular object, together they are heavy enough to break it. How can I write this for the trigger, to always add the specific weight that each character has if it enters the trigger? And in case, one character moves away before the trigger-object breaks, how to subtract it? Thanks a lot!

On the ‘scale’ object I imagine you could do something like:

private float WeightOnScale;

void OnTriggerEnter(Collider other)
{
    ObjectType playerScript = other.GetComponent("NAME OF OBJECT WITH CHARACTER WEIGHT");
    WeightOnScale += playerScript.WeightVariable;

}

void OnTriggerExit (Collider other)
{
    ObjectType playerScript = other.GetComponent("NAME OF OBJECT WITH CHARACTER WEIGHT");
    WeightOnScale -= playerScript.WeightVariable;
}

That code probably won’t compile, and certainly won’t win any best practices awards, but might be a good place to start?

I guess you would then have a check in Update() that kicks off a DoSomething() function once WeightOnScale is >= your target value.

ALTERNATIVELY:
If you know that only players are going to trigger the scale (which you could do with collidable settings and putting the scale on its own specific layer), you could just increment a “How many people are on the scale” integer OnTriggerEnter and decrement it OnTriggerExit.