hi i made one of the ennemy’s in my game follow the player. But when the player dies i have a error message that says that the ennemy is searching for the player so it cant reload the level
there is my script (its in JavaScript):
var target :Transform;
var minRange:int;
var follow:boolean;
var speed:float;
function Update(){
if(Vector3.Distance(transform.position,target.position)<minRange)
follow=true;
if(follow){
transform.LookAt(target);
transform.Translate(Vector3.forward *speed* Time.deltaTime);}
}
How can i make the ennemy stop following the player when he id dead?