Unity Destroy Object by Hit

Unity Destroy Object by Hit

Before implement this code, please check if you add “Rigidbody” component to your objects and “Is Trigger” box is selected. Otherwise, it doesn’t work.

void OnTriggerEnter(Collider c)
{
 if (c.collider.tag == "Enemy")
 {
  Destroy(c.gameObject);
 }
}

Unity Destroy Object by Hit