Hello I am having trouble with my lookAt script I made heres the one that would work
var target : Transform;
function Update () {
transform.LookAt(target);
}
but the object is going to spawn when my enemy dies so the target wont be set when it spawns here is what I tried for an example of what I am trying to do
var target;
function Update () {
target = gameObject.Find("Player");
transform.LookAt(target);
}
var target : GameObject;
function Update () {
target = gameObject.Find("Player");
transform.LookAt(target.transform);
}
From the docs:
“For performance reasons it is recommended to not use this function every frame Instead cache the result in a member variable at startup or use GameObject.FindWithTag.”