I have enemies with ai's that follow you around but the enemy can basically walk up any slope no matter how steep. How can I stop it from doing this? Also sometimes whenever they hit a wall or something they go awol and just start running in random directions. by the way i got this script online and have no idea what im doing with it (sorry for my noobishness)
#pragma strict
var Player : Transform;
var MoveSpeed = 4;
var MaxDist = 10;
var MinDist = 5;
function Start ()
{
}
function Update ()
{
transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position) >= MinDist){
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
{
//call function here
}
}
}
↧