unity detect collision by tag code example
Example 1: how to check the tag of a collider in unity
void OnTriggerEnter(Collider collision)
{
if(collision.gameObject.tag == "[Tag]")
{
//Do Something...
}
}
Example 2: how to do collision tag in unity
void OnColliSionEnter2D(Collision col){
if (col.gameobject.tag == "Enemy"){
Destroy(gameObject)
}
}