I have some game objects on screen and added a polygon collider on them to detect normal collision with them. I would like to add a box collider on their head to detect headshot. How can i do this please? How can i state collision with box collider instead of polygon collider in C# please?
i tried this but only the polygon collider is getting detected
void OnCollisionEnter2D(Collision2D col) {
if(col.gameObject.tag == "target")
{
score += 1000;
gameObject.SetActive (false);
gameObject.SetActive (true);
Destroy (col.gameObject);
}
else if(col is BoxCollider2D)
{
score += 2000;
gameObject.SetActive (false);
gameObject.SetActive (true);
Destroy (col.gameObject);
}
}