Object shattering under a certain weight/force

Lets say I want to create a situation where a player has to walk on ice, or a glass panel. The glass panel/ice has a certain value of strength, and if the force applied to it is greater, it falls off/breaks. How would I go about this? I want it to shatter under “static” weight of a single heavy objects or multiple lighter ones, and also if someone threw a lighter object at it with great enough velocity.

To put it in pseudo:

if (sumOfAllForcesApplied  > objectStrength){
    Instantiate(destroyedVersion, transform.position, transform.rotation);
    Destroy(gameObject);
}

Thanks in advance.

I suppose there is a way to do it with addForce and gravity and whatnot. But I would Forest Gump something together like this - which would be a pain if you have a LOT of possible objects, but I would just assign an integer (weight) to those possible objects. a rock could be 10, a sofa 150, a person 210 etc . etc. Have a trigger zone on the ice where if an object enters it adds that integer, if the weight exceeds breaking point

using UnityEngine;
using System.Collections;//code on the ice

public class iceBreaks : MonoBehaviour {

public static int  weight = 0;//this will grow as objects enter the trigger zone
public int breakingWeight = 230;//whatever strength you want the ice to be
Animation ani;

void Start(){
ani = GetComponent<Animation>();
}

void Update(){
if( weight >= breakingWeight)
ani.Play ("iceBreaks");
}
}
}
______________________________________________________________________________________

//code can go on all objects just change the thisObjectsWeight

using UnityEngine;
using System.Collections;

public class objectWeight : MonoBehaviour {
 MonoBehaviour  weight;
public GameObject ice;
public int thisObjectsWeight = 15;

void Start (){

weight = ice.GetComponent<iceBreaks>();//this will access the static variable weight from ice script
}

void OnTriggerEnter (Collider other) {
		if(other.tag == "ice")

iceBreaks.weight += thisObjectsWeight;

}
}
}

Had to play with this a bit after adding my comment above. I’ve only done limited testing on this, but seems to work as desired. Add this component to the rigid body that should break up.

This works with impacts at speed (smash), and with objects simply sitting on each other (but NOTE: in this case, the impulse is non-zero ONLY when the mass of one of the colliding rigid bodies changes.) Keep in mind; kenetic energy is mass times velocity SQUARED, so a change in the speed of impact will affect the “impulse” more than a similar change in mass (e.g. carefully placing a large brick on an ice cube with your hand, vs shooting the ice cube with a tiny bullet).

public class ShatterBody : MonoBehaviour {
    public float breakingImpulse = 5.0f;
    public bool alreadySmashed=false;
    private void OnCollisionEnter(Collision collision)
    {
        if (alreadySmashed) return;
        if (collision.impulse.magnitude > breakingImpulse)
        {
            Debug.Log("Smash! I'm breaking up!");
            alreadySmashed = true;
        }
    }
    private void OnCollisionStay(Collision collision)
    {
        if (alreadySmashed) return;
        if (collision.impulse.magnitude > breakingImpulse)
        {
            string s = "Too heavy, I'm breaking up!";
            
            if(collision.rigidbody.isKinematic)
                s += "Under my own weight";
            else
                s += "under the weight of " + collision.rigidbody.gameObject.name;
            Debug.Log(s);
            alreadySmashed = true;
        }
    }
}

The answer obviously depends on how complex you want to get, so I’ll just write what I guess I would do. In your ice plane case, i would simply assume that the strain on the structure equals the downwards force onto it (which is obviously not fully correct).

For resting objects, the gravitational downwards force is about 1 N per kg. Biggest problem for summing that up are stacked objects. You would have to maintain the network of rigid bodies that touch each other and apply their summed force to the plane.

For impacts/new collisions, the force is about their speed * their mass * the dot product of their movement direction and the down vector (since we are only concerned about downwards force). Apply that force over a short period of time, like 0.3s, and divide the force by that number (this number depends on softness of the object / flexibility of the plane)

Finally, make the plane shatter when the summed forces exceed a certain limit.
I think that could give acceptable first results.