Certain amount of force

I need to destroy some objects in this game when certain amount of force is applied to it. How is it possible to implement it?

You’ll want a component on the items you want to be destructible… something like

public class Destructable: MonoBehaviour
{
      [SerializeField] float threshHold = 10f;
      void OnCollisionEnter2D(Collision2D other) 
      {
           if(other.relativeVelocity.magnitude>threshhold)
           {
                 Destroy(gameObject);
           }
       }

}
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms