If 2 collisions happen simultaneously, how can I make OnTriggerEnter2D still work?
I'm making a tower defence game, and I did the tower's ranges by constantly enabling and disabling the collider that represented the range. Problem is, this means multiple collisions are happening on the same frame, and the code I want to happen isn't happening. How can I fix this?
private void OnTriggerEnter2D(Collider2D collision)
{
//This is so I know the position at which the collision occured, so I can spawn the attack there
//7 is the layer all enemies are on and nothing else, so this line checks it is an enemy
if (collision.gameObject.layer == 7)
{
if (Can_Attack==true)
{
//This sets Collision_Co_Ords to the position of the enemy
Attack(collision.gameObject.transform.position);
}
}
}