Hi all,
i am learning about the process of making games and i’m currently complete noob. I make a zombie game based on Angry Bots character, i have a zombie model from PixelHouse, i’ve found an AI script for this zombie here .
var player : GameObject; var speed : float = 1;
function Start () { player = GameObject.FindGameObjectWithTag("Player");
if (!player)
Debug.Log ("ERROR could not find Player!");
}
function Update() { if (!player) return;
var distance = Vector3.Distance( player.transform.position, transform.position);
if ( distance < 60 )
{
Debug.Log ("player is close");
var delta = player.transform.position - transform.position;
delta.Normalize();
var moveSpeed = speed * Time.deltaTime;
transform.position = transform.position + (delta * moveSpeed);
}
else
{
Debug.Log("not close yet " + distance);
}
}
That’s the code. Also thank you, goatria!
However i have a small problem. I don’t know how (and where exactly) to insert an animation events in this script. I know that this is kinda simple, but as i mentioned it above, i am completly newb in scripting.
Here is a preferences of zombie.
Heres the video of da game. As you see, following player works, i want to make animation work too.
Any help appreciated.