This is the script that I currently have. It is on the NPC and when the spawn trigger is hit the NPC is spawned with this script on it. it will turn and chase the player currently however, i want it to stay within a certain radius until the player enters that circle and then chase the player. if the player is out of that radius then I want the NPC to go back to the original spawn point. it is set with an empty game object labeled spawnpoint1.
#pragma strict
var player = Transform;
var speed : float = 2; // well...the speed
var controller:CharacterController;
function Start(){
controller = gameObject.GetComponent(CharacterController);
}
function Update(){
transform.LookAt(GameObject.FindWithTag("Player").transform); // the NPC looks at the player
// Here you access the Character Controller component and move your NPC with SimpleMove() giving the speed and the direction(forward).
//As the NPC is looking at you, forward is in your direction.
controller.SimpleMove(speed*transform.forward);
animation.Play("WalkForwardNoGun"); //You play the animation
}
any thoughts as to how I can accomplish this?