I want to have a monster spawn in game then chase the player, Only problem is i cant figure out how to get it to find the player while in game. I know how to do it though the hireachy.
var target : Transform; //This is what i need to do target=transform.Find("Player"); with, But i cant get it to work
var MoveSpeed = 7;
var MaxDist = 0;
var MinDist = 5;
var Health : float=150;
function Awake(){
}
function Update ()
{
if(Health<=0){
Destroy (gameObject);
}
transform.LookAt(target);
if(Vector3.Distance(transform.position,target.position) >= MinDist){
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
if(Vector3.Distance(transform.position,target.position) <= MaxDist)
{
}
}
}
function DoDamage(d){
Debug.Log("FurryHit");
Health-=d;
}
The script above WORKS, its just i want this prefab to spawn then chase the player. but again i cant get it to link and get the var target to be the player while in game.
how could i do this?