(Unity)ある物に触れたら画面上の敵の追跡速度が変化する(foreachの活用)

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class EnemySpeedUp : MonoBehaviour
{
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            this.gameObject.SetActive(false);

            GameObject[] enemies = GameObject.FindGameObjectsWithTag("EnemyB");

            foreach (GameObject e in enemies)
            {
                e.GetComponent<NavMeshAgent>().speed = 10;
            }
        }
    }
}