Trigger all enemies

Hey! I made a new script which triggers all enemies by one shot.

EnemyAI:

public void OnDamageTaken() 
    {
       // IsProvoked = true;
        AIManager = FindObjectOfType<AIManager>();
        AIManager.triggerAllEnemies();

    }

AIManager:

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

public class AIManager : MonoBehaviour
{
    [SerializeField] List<EnemyAI> NPCs = new List<EnemyAI>();
    

    public void triggerAllEnemies() 
    {
        foreach(EnemyAI enemy in NPCs) 
        {
            enemy.IsProvoked = true;
        }
    }

}
2 Likes

Privacy & Terms