Unity проблема с преследованием юнитов

есть враг с тегом Enemy есть защитник который ищет юнита с тегом Enemy После того как защитник убивает одно юнита с тегом Enemy он не бежит к другим юнитам с тегом Enemy, а просто останавливается и всё

public float Speed;
private float TimeBtwAttack;
public float StartTimeBtwAttack;
public float stoppingDistance;
Enemy _enm;
private Transform target;
Animator anim;

void Start()
{
    _enm = FindObjectOfType<Enemy>();
    anim = GetComponent<Animator>();
    target = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Transform>();
}

private void Update()
{
    if(target.transform.position.x < transform.position.x)
    {
        transform.eulerAngles = new Vector3(0, 180, 0);
    }
    else
    {
        transform.eulerAngles = new Vector3(0, 0, 0);
    }

    if (Vector2.Distance(transform.position, target.position) > stoppingDistance)
    {
        transform.position = Vector2.MoveTowards(transform.position, target.position, Speed * Time.deltaTime);
    }
}



private void OnTriggerStay2D(Collider2D other)
{
    if (other.CompareTag("Enemy"))
    {
        if (TimeBtwAttack <= 0)
        {
            anim.SetTrigger("Attack");
            _enm.HP--;
            TimeBtwAttack = StartTimeBtwAttack;
        }
        else
        {
            TimeBtwAttack -= Time.deltaTime;
        }
    }
}

}


Ответы (0 шт):