I have a bullet script that trigger on collision with an enemy, problem is when two enemies colliders overlaps and trigger with bullet both disapear instead of one only. Is there any way to only trigger one?
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.GetComponent<Enemy>())
{
collision.GetComponent<Enemy>().DisableUnit();
gameObject.SetActive(false);
}
}