Hello everyone, I need help for my AI script. I have my enemy AI script almost ready. My enemies have “playerDetected” value. If this value is true they start shooting. So I want this value to be true when player shoots. I did :
function Shoot(){
var target = GameObject.FindWithTag("Enemy");
var scr = target.GetComponent(EnemyAI);
scr.playerDetected=true;
}
this script works perfect only if there is one enemy in the scene. When I put 2 or more enemies to the scene, only one of them starts shooting. Basically what I want to do is, when I shoot all the objects tagged “Enemy” will change their playerDetected value to true in their scripts. Any ideas ? Thanks :).