This is my first post so apologies for the scurviness.
So think of my gameObject as an egg. I want it to be destroyed if it hits the ground too hard, as well as break when another object is dropped on it. The code I am using works for the most part, however the gameObject only breaks when an object with velocity hits it, not when it hits an object with no velocity, i.e. the ground. Here is what I am working with (C#):
public GameObject broken;
public float force;
void OnCollisionEnter(Collision collision)
{
if (collision.relativeVelocity.magnitude > force)
{
Destroy(gameObject);
Instantiate(broken, transform.position, transform.rotation);
}
}
So does anyone know how I can make the gameObject be destroyed if a certain force is applied whether or not it is hitting something or being hit by something?
Thanks!