unity on collision destroy object code example
Example: unity destroy object on collision
void OnCollisionEnter2D(Collision2D coll)
}
// Check if we have collided with the enemy
if (coll.gameObject.tag == "Enemy")
{
Destroy(coll.gameObject);
}
}