So guys, I have obtained this resource from a site and it had this controller. Now, I am trying to get it so that when the player car gets to a certain point, the enemy chases him. Then, when he is 2 metres away, the enemy kills him. I have it so he does that but he does NOT face me! D-X Any ideas?;
var theplayer : GameObject;
var speed : float;
var range : int;
function Update (){
//calculate the distance between the enemy and the player
range=Vector3.Distance(theplayer.transform.position,transform.position);
//AWARENESS- make the enemy look at the player when within 66 metres
if(range<67){
transform.LookAt(theplayer.transform.position);
}
//CHASE- move toward the player when within 45 and 60 metres
if (range<60&&range>45){
transform.Translate(Vector3.forward*speed);
}
//DESTROY- Destroy car with death roar when within 2 metres
if(range<3){
animation.Play("scream");
Destroy(theplayer);
}
}
P.S The player is set as the player car and I WILL NOT give the resource link because the site SPECIFICALLY prefered I do not reveal the resource .