Hi,
I'm currently working on a 2d game but I'm stuck on the enemy AI.I want it to go to the target which the player. I've shearched on the internet but there wasn't any tutorials. I've tried myself but I have a problem with transform.LookAt() which isn't for 2D.
Here is my script :
var Player : Transform;
var Speed = 4;
var Dist = 5;
function Start ()
{
}
function Update ()
{
transform.LookAt(Player.transform.position);
if(Vector3.Distance(transform.position,Player.position) >= Dist)
{
transform.position += transform.forward*Speed*Time.deltaTime;
}
}
Thanks for you help.
↧